ReSift

ReSift

  • Docs
  • API
  • Help
  • GitHub

โ€บAPI

Introduction

  • What is ReSift?
  • Installation

Tutorial

  • ReSift Rentals

Main Concepts

  • What's a fetch?
  • How to define a fetch
  • Making state consistent
  • Making sense of statuses
  • What are data services?
  • Error handling
  • Custom hooks

Examples

  • ReSift Notes (CRUD)
  • Infinite scroll
  • Custom hooks and React Router

Guides

  • ReSift vs Apollo and Relay
  • HTTP proxies
  • Usage with TypeScript
  • Usage with Redux
  • Usage with classes

API

  • About these docs
  • useStatus
  • useError
  • useDispatch
  • useData
  • useClearFetch
  • isUnknown
  • isNormal
  • isLoading
  • isError
  • defineFetch
  • dataServiceReducer
  • createStoreKey
  • createHttpService
  • createHttpProxy
  • createDataService
  • createActionType
  • combineStatuses
  • ResiftProvider
  • Guard
  • CanceledError
  • UNKNOWN
  • NORMAL
  • LOADING
  • ERROR
Edit

createHttpService API

These docs are auto-generated from typings files (*.d.ts).

HttpParams

If you're looking for the params for the http calls inside a fetch factory's request, you've found 'em!

e.g.

const makePersonFetch = defineFetch({
  displayName: 'Get Person',
  make: personId => ({
    request: () => ({ http }) =>
      http({
        // see below for what can go here
        // ๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡๐Ÿ‘‡
      })
  })
});

The HTTP Service uses superagent behind the scenes.

NameDescriptionTypeRequired
methodThe HTTP method to use.'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'yes
routeThe route to use.stringyes
queryAn object representing the query parameters to serialize to the URL.

{foo: ['bar', 'baz'], hello: 'world'} ==> ?foo=bar&foo=baz&hello=world
{ [key: string]: string }no
dataThe data to be sent to the URL. If this is an object, it will be serialized to JSON. Sending
a FormData object is also supported.
anyno
okThis is directly upstream's .ok method:

http://visionmedia.github.io/superagent/#error-handling

"Alternatively, you can use the .ok(callback) method to decide whether a response is an
error or not. The callback to the ok function gets a response and returns true if the
response should be interpreted as success."
(response: request.Response) => booleanno
reqYou can add custom behavior to the superagent req using this callback.
it is added before the req.send method is called
(request: request.SuperAgentRequest) => voidno

createHttpService

Give the required HttpServiceParams, this function returns an HTTP service ready to be put into the services object in createDataService.

function createHttpService(params: HttpServiceParams): HttpService;

HttpServiceParams

The params that can be passed into the createHttpService function.

NameDescriptionTypeRequired
getHeadersProvide a function to the HTTP service to return headers for the request. Use this to inject
any authentication tokens.
(() => any) | (() => Promise)no
prefixUse this to prefix all requests with a certain path. e.g. /apistringno
getPrefixUse this to dynamically determine the prefix.(() => string) | (() => Promise)no
proxiesPass any proxies into the HTTP service here. Create the proxy with
createHttpProxy first.
HttpProxy[]no
โ† createStoreKeycreateHttpProxy โ†’
  • HttpParams
  • createHttpService
  • HttpServiceParams
ReSift
Docs
What is ReSift?What's a fetch?API
Community
Ask a questionOpen an issue@ meLeave feedback
More
StarBuild StatusCoverage Status
Copyright ยฉ 2021 Sift
www.justsift.com