tg-resources Fetch backend
Notice: This package expects fetch
, Request
, Response
and FormData
to be available in global scope, e.g in window
for Browser or in global
for Node.js
Installing
Using NPM
npm i tg-resources @tg-resources/fetch
Or using Yarn
yarn add tg-resources @tg-resources/fetch
Does it work on react native?
YES
Basic Usage
const onLoad = console;const onError = console; const api = cats: '/cats' cat: '/cats/${pk}' apiRoot: '/api/v1' // Set api root; // Do a get request to /api/v1/cats?gender=Mapicats; // Do a head request to /api/v1/cats?gender=Mapicats; // Do a post request to /api/v1/cats with data: {name: 'Twinky', gender: 'M'}apicats; // Do a patch request to /api/v1/cats/1 with data: {name: 'Tinkelberg'}apicat; // Do a put request to /api/v1/cats with data: {pk: 1, name: 'Twinky'}apicats; // Do a delete request to /api/v1/cats/1 with data: {'free':'yes'}apicat;
Configuration
This package adds extra configuration methods for Router
and FetchResource
.
querySerializeOptions
(Object|undefined): Advanced usage: Options to configure query-string serialization. See qs.stringify.
This package is just Resource implementation using fetch
.
For additional configuration, see Configuration.
License
MIT © Thorgate