isomorphic-fetch-http
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -33,2 +33,3 @@ 'use strict'; | ||
* @param {object} [options] The options we want to pass to "fetch" | ||
* @param {object} header The request header | ||
* @return {object} An object containing either "data" or "err" | ||
@@ -40,3 +41,3 @@ */ | ||
return (0, _isomorphicFetch2.default)(url, _extends({}, httpConfig, { headers: _extends({}, httpConfig.headers, header) }, option)).then(function (resp) { | ||
return (0, _isomorphicFetch2.default)(header.prefix ? '' + header.prefix + url : url, _extends({}, httpConfig, { headers: _extends({}, httpConfig.headers, header) }, option)).then(function (resp) { | ||
if (resp.status >= 400) { | ||
@@ -43,0 +44,0 @@ throw new Error('400+Error'); |
{ | ||
"name": "isomorphic-fetch-http", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "react fetch by isomorphic-fetch", | ||
@@ -5,0 +5,0 @@ "main": "lib/isomorphic-fetch-http.js", |
@@ -22,3 +22,2 @@ ## isomorphic-fetch-http | ||
- [Home page](https://github.com/jindada/react-http) | ||
- [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) | ||
@@ -29,2 +28,2 @@ | ||
You can submit any ideas as [pull requests](https://github.com/jindada/isomorphic-fetch-http) or as a [GitLab issue](https://github.com/jindada/isomorphic-fetch-http/issues). | ||
You can submit any ideas as [pull requests](https://github.com/jindada/isomorphic-fetch-http) or as a [Github issue](https://github.com/jindada/isomorphic-fetch-http/issues). |
@@ -19,6 +19,7 @@ import fetch from 'isomorphic-fetch'; | ||
* @param {object} [options] The options we want to pass to "fetch" | ||
* @param {object} header The request header | ||
* @return {object} An object containing either "data" or "err" | ||
*/ | ||
const $http = (url, option = {}, header = {}) => { | ||
return fetch(url, { ...httpConfig, headers: { ...httpConfig.headers, ...header }, ...option }) | ||
return fetch(header.prefix ? `${header.prefix}${url}` : url, { ...httpConfig, headers: { ...httpConfig.headers, ...header }, ...option }) | ||
.then((resp) => { | ||
@@ -25,0 +26,0 @@ if (resp.status >= 400) { |
8307
111
28