isomorphic-fetch-http
Advanced tools
Comparing version 0.2.5 to 1.0.0
@@ -127,2 +127,9 @@ 'use strict'; | ||
}, { | ||
key: 'options', | ||
value: function options(url, param) { | ||
var header = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
return this[http](url, { method: 'OPTIONS' }, header); | ||
} | ||
}, { | ||
key: 'option', | ||
@@ -133,4 +140,13 @@ value: function option(url) { | ||
console.log("WARNING: 在isomorphic-fetch-http 1.0.0版本及以上版本,option方法已经由json方法代替,option方法将在1.1.0版本中去除"); | ||
return this[http](url, { method: 'POST', body: JSON.stringify(param) }, _extends({}, header, { "Content-Type": "application/json" })); | ||
} | ||
}, { | ||
key: 'json', | ||
value: function json(url) { | ||
var param = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var header = arguments[2]; | ||
return this[http](url, { method: 'POST', body: JSON.stringify(param) }, _extends({}, header, { "Content-Type": "application/json" })); | ||
} | ||
}]); | ||
@@ -137,0 +153,0 @@ |
{ | ||
"name": "isomorphic-fetch-http", | ||
"version": "0.2.5", | ||
"version": "1.0.0", | ||
"description": "react fetch by isomorphic-fetch", | ||
@@ -5,0 +5,0 @@ "main": "lib/isomorphic-fetch-http.js", |
@@ -27,25 +27,42 @@ ## isomorphic-fetch-http | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.get('url', param); | ||
return http.get('url', param, header); | ||
// post方法 一般用于数据提交 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.post('url', param); | ||
return http.post('url', param, header); | ||
// put方法 一般用于数据修改 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
// return http.put('url', param); | ||
return http.put('url', param, header); | ||
// delete方法 一般用于数据删除 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.delete('url', param); | ||
return http.delete('url', param, header); | ||
// json方法 本质是请求头为 "Content-Type": "application/json" 的post方法 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.json('url', param, header); | ||
// option方法 本质是请求头为 "Content-Type": "application/json" 的post方法 | ||
// WARNING: 在isomorphic-fetch-http 1.0.0版本及以上版本,option方法已经由json方法代替,option方法将在1.1.0版本中去除 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.option('url', param); | ||
return http.option('url', param, header); | ||
// options方法 一般用于请求时的预检 | ||
// @param {Object} param | ||
// @param {Object} header | ||
// @return {Object} {status, data, message} | ||
return http.options('url', param, header); | ||
``` | ||
@@ -52,0 +69,0 @@ |
@@ -79,8 +79,17 @@ import fetch from 'isomorphic-fetch'; | ||
} | ||
options(url, param, header = {}) { | ||
return this[http](url, {method: 'OPTIONS'}, header); | ||
} | ||
option(url, param = {}, header) { | ||
console.log("WARNING: 在isomorphic-fetch-http 1.0.0版本及以上版本,option方法已经由json方法代替,option方法将在1.1.0版本中去除"); | ||
return this[http](url, {method: 'POST', body: JSON.stringify(param)}, {...header, "Content-Type": "application/json"}); | ||
} | ||
json(url, param = {}, header) { | ||
return this[http](url, {method: 'POST', body: JSON.stringify(param)}, {...header, "Content-Type": "application/json"}); | ||
} | ||
} | ||
export default new _http(); |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19785
372
1
78