jfetch
jfetch is a small library that makes it easier to use the fetch library. Use it if you
have an all json communication with your rest endpoint
Install
npm install --save jfetch
Usage
import jfetch from 'jfetch';
const { jfetch } = require('jfetch');
const jfetch = require('jfetch').default;
Quick Usage
jfetch('/api/inventories')
.then( processJson );
jfetch.post('/api/inventories', { id: 'xY33bG', name: 'New Inventory' })
.then( processJson );
Customizing Jfetch
You can use jfetch such that you are able to change the behavior on how each of the requests behaves.
This is done using the createJfetch function.
import { createJfetch } from 'jfetch';
const jfetch = createJfetch({ autoBust: false });
jfetch('/api/inventories').then(...);
Settings for custom jfetch
- withConfig - function that returns an extra configuration to be merged with the requests
- onRespose - function that can receive response data