Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
isomorphic-fetch-http
Advanced tools
npm install isomorphic-fetch-http --save
import { http } from 'isomorphic-fetch-http'
http.setup({
cookies: true,
});
return http.get('url', param, header);
全局配置
prefix
请求 url 前缀
headers
配置请求头
cookies
是否携带cookies
filter
过滤函数,发生在请求发出之前,可以对url, headers,fetch option进行更改,类型为 Promise function。
http.setup({
filter: data => new Promise((resolve, reject) => {
// 获取
const { url, headers, option } = data;
// 修改
const newHeaders = {
...headers,
token: 'zhnagsan'
};
// 返回
resolve({ url, headers: newHeaders, option });
})
});
callback
回调数据函数,对请求成功获取到的数据进行预处理
http.setup({
callback: data => {
const { status, data, messgae } = data;
if (status) {
return data;
} else {
throw new Erroe(message);
}
}
get 方法,一般用于数据查询
return http.get('/get', {currentPage: 1}, {token: 'zhangsan'}); // 此处的headers优先级最高
post 方法,一般用于数据提交
return http.post('/add', {username: 'zhangsan'});
put 方法,一般用于数据修改
return http.put('/update/1', {username: 'lisi'});
delete 方法,一般用于数据删除
return http.put('/delete/1');
请求头 "Content-Type" 为 "application/json" 的 post 方法
return http.post('/add', {username: 'zhangsan'});
option 方法,一般用于请求时的预检
You can submit any ideas as pull requests or as a Github issue.
FAQs
react fetch by isomorphic-fetch
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
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.