isomorphic-fetch-http
Install
npm install isomorphic-fetch-http --save
Usage
http; return http;
Options
setup
全局配置
prefix
请求 url 前缀
headers
配置请求头
cookies
是否携带cookies
filter
过滤函数,发生在请求发出之前,可以对url, headers,fetch option进行更改,类型为 Promise function。
http;
callback
回调数据函数,对请求成功获取到的数据进行预处理
http
get
get 方法,一般用于数据查询
return http; // 此处的headers优先级最高
post
post 方法,一般用于数据提交
return http;
put
put 方法,一般用于数据修改
return http;
delete
delete 方法,一般用于数据删除
return http;
json
请求头 "Content-Type" 为 "application/json" 的 post 方法
return http;
options
option 方法,一般用于请求时的预检
Links
Contributing
You can submit any ideas as pull requests or as a Github issue.