createJsonMutation
since v0.2
Formulae
createJsonMutation(config)
Config fields:
params?
: parameters for the Mutationrequest
: declarative rules to formulate request to the API.method
: Stringurl
: Sourced stringbody
: Sourced Json, any value which can be serialized to JSON and parsed back without loses by JavaScript native module JSON. For example,{ a: 1, b: 2 }
. Note that body cannot be used inGET
andHEAD
requests.query?
: Sourced object, keys of the object must beString
and values must beString
orArray<String>
or (since v0.8) Sourced String containing ready-to-use query stringheaders?
: Sourced object, keys of the object must beString
and values must beString
orArray<String>
credentials?
: since v0.7 String, available values:omit
— do not include credentialssame-origin
— include credentials only if the request URL is the same origininclude
— include credentials on all requests
response
: declarative rules to handle response from the API.contract
: Contract allows you to validate the response and decide how your application should treat it — as a success response or as a failed one.validate?
: Validator allows you to dynamically validate received data.mapData?
: optional mapper for the response data, available overloads:(res) => mapped
{ source: Store, fn: (data, res) => mapped }
res
object contains:result
: parsed and validated response dataparams
: params which were passed to the Mutationheaders
: since v0.13 raw response headers
status.expected
:number
orArray<number>
of expected HTTP status codes, if the response status code is not in the list, the mutation will be treated as failed
concurrency?
: concurrency settings for the MutationDeprecation warning
This field is deprecated since v0.12 and will be removed in v0.14. Use
concurrency
operator instead.Please read this ADR for more information and migration guide.
abort?
: Event after calling which all in-flight requests will be aborted