Fetch plugin
syncedFetch
is a simple wrapper around fetch
to reduce boilerplate.
get
: The URL to get. If it is an observable or Selector function, it will re-run whenever the value changes.set
: The URL to setgetInit
: Theinit
parameter to pass tofetch
when gettingsetInit
: Theinit
parameter to pass tofetch
when setting. Defaults to{ method: 'POST' }
valueType
: The function to call on the Response set. Defaults tojson
.onSavedValueType
: The function to call on the Response from set. Defaults to thevalueType
option orjson
.onSaved
: Given the return value from set, return a value to save back into the observable.
Example: