Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
isomorphic-fetch-http
Advanced tools
npm install isomorphic-fetch-http --save
import { http } from 'isomorphic-fetch-http'
// isomorphic-fetch-http 要求数据返回格式为
{
status: true, // 请求状态 true/false
code: 'INVALIDError', // 发生特定异常返回的错误码 与 exception 对应
data: {} / [] // 请求状态为 true 时返回的数据体
message // 请求状态为 false 时返回的详细错误信息
}
// 全局配置
http.setup({
prefix: '/api', // url 前缀
header: {}, // 自定义请求头
filter: { // 自定义过滤器 before 发生在请求执行之前 after 发生在请求执行之后
before: () => false,
after: () => false
}
exception: ['INVALIDError'] // 自定义捕获类型
});
http.setHeader({ // 覆盖/新增 请求头
token: ''
})
// get方法 一般用于查询
// @param {Object} param
// @param {Object} header
// @return {Object} {status, data, message}
return http.get('url', param, header);
// post方法 一般用于数据提交
// @param {Object} param
// @param {Object} header
// @return {Object} {status, data, message}
return http.post('url', param, header);
// put方法 一般用于数据修改
// @param {Object} param
// @param {Object} header
// @return {Object} {status, data, message}
return http.put('url', param, header);
// delete方法 一般用于数据删除
// @param {Object} param
// @param {Object} header
// @return {Object} {status, data, message}
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, header);
// options方法 一般用于请求时的预检
// @param {Object} param
// @param {Object} header
// @return {Object} {status, data, message}
return http.options('url', param, header);
You can submit any ideas as pull requests or as a Github issue.
FAQs
react fetch by isomorphic-fetch
The npm package isomorphic-fetch-http receives a total of 3 weekly downloads. As such, isomorphic-fetch-http popularity was classified as not popular.
We found that isomorphic-fetch-http demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.