Comparing version 0.6.0 to 0.7.0
{ | ||
"name": "fitch", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "A lightweight Promise based HTTP client, using Fetch API.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ ![Fitch.js](https://github.com/raphaelpor/fitch.js/raw/master/assets/fitch-mini.png) | ||
[![npm version](https://badge.fury.io/js/fitch.svg)](https://badge.fury.io/js/fitch) | ||
[![npm version](https://badge.fury.io/js/fitch.svg)](https://www.npmjs.com/package/fitch) | ||
[![Build Status](https://travis-ci.org/raphaelpor/fitch.js.svg?branch=master)](https://travis-ci.org/raphaelpor/fitch.js) | ||
@@ -8,0 +8,0 @@ [![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://github.com/raphaelpor/fitch.js/blob/master/docs/Intro.md) |
@@ -33,19 +33,23 @@ require('es6-promise').polyfill(); | ||
} | ||
const configObj = config.create(method, req); | ||
const call = fetch(url + paramsEncoded, configObj); | ||
return req.raw ? call : call.then(this.check); | ||
return req.raw ? call : call.then(resp => this.check(resp, req.dataType)); | ||
}, | ||
check(resp) { | ||
if (resp.ok) { | ||
return resp.json(); | ||
check(resp, dataType = 'json') { | ||
const typeList = ['arrayBuffer', 'blob', 'formData', 'json', 'text']; | ||
const included = typeList.indexOf(dataType); | ||
if (resp.ok && included !== -1) { | ||
return resp[dataType](); | ||
} | ||
throw new Error(`${resp.status} - ${resp.statusText}.`); | ||
}, | ||
error(err) { | ||
if (err) { | ||
console.log('Error >', err); | ||
} | ||
error(err = '') { | ||
console.log('Error >', err); | ||
}, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32734
15