0.1.6 • Published 7 years ago

jfetch v0.1.6

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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

//es6 modules
import jfetch from 'jfetch';

//amd
const { jfetch } = require('jfetch');
//amd alt
const jfetch = require('jfetch').default;

Quick Usage

//standard get 

//process json here is a function
jfetch('/api/inventories')
    .then( processJson );

//post
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'; //es6 modules

//const { createJfetch } = require('jfetch'); //amd

const jfetch = createJfetch({ autoBust: false });

jfetch('/api/inventories').then(...); //...will not auto bust get

Settings for custom jfetch

  1. withConfig - function that returns an extra configuration to be merged with the requests
  2. onRespose - function that can receive response data
0.1.6

7 years ago

0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago