Network configuration
To use the network layer, you should check/update the following options:
baseUrl
- The base path to the API. Default is"/"
, but could be something like"https://example.com/api/"
- Model
endpoint
- Path to the model type on the API. If not defined, it will use the model type. This can be used if the url needs to be prefixed (e.g. model scoping) or e.g. if the url is in plural, but the model type is in singular. Using the endpoint function allows you to override thebaseUrl
in case some models need a different base URL. fetchReference
- Set towindow.fetch
by default, but can be set to some otherfetch
implementation, e.g.isomorphic-fetch
defaultFetchOptions
- If needed, you can define default options that are passed to the fetch method. Keep in mind that the body and method properties will be overridden. By default, it is setting thecontent-type
header according to the JSON API specification
If you want to use some other method of communication with the server (e.g. jQuery, superagent or axios), you can override the baseFetch
method.
If you need to transform the request and response data dynamically (e.g. setting or getting API tokens/session tokens), you can use transformRequest
and transformResponse
.
For a detailed specification of the available options, check out the config options.