0.0.8 • Published 9 years ago

jsyg-fetch v0.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

JSYG.fetch

fetch polyfill with control of http status : the promise will be rejected if the status is ( < 200 and != 0) or ( >= 300 and != 304 ).

Installation

npm install jsyg-fetch

You can also install it with bower

Usage with webpack/babel

import fetch from "jsyg-fetch"

fetch("http://myDomain/my/query/")
.then( response => response.json() )
.then( obj => console.log(obj) )
.catch( e => {
    
    e instanceof Error //true
    
    if (e.response.status == 400) console.error("this is a bad request")
})