iota-fetch 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,11 +15,11 @@ const requestConfig = {};
|
|
|
15
15
|
//loading -> loading.show() loading.hide()
|
|
16
16
|
const { fetch, instance } = createFetch({ requestConfig, loading})
|
|
17
17
|
|
|
18
|
-
// fetch 请求方法 fetch.get fetch.post fetch.put ...
|
|
18
|
+
// fetch 请求方法 fetch.get fetch.post fetch.put ...
|
|
19
19
|
// 创建的axios 实例 instance 添加拦截器
|
|
20
20
|
|
|
21
21
|
// 添加请求拦截器
|
|
22
|
-
|
|
22
|
+
instance.interceptors.request.use(function (config) {
|
|
23
23
|
// 在发送请求之前做些什么
|
|
24
24
|
return config;
|
|
25
25
|
}, function (error) {
|
|
@@ -28,7 +28,7 @@ axios.interceptors.request.use(function (config) {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// 添加响应拦截器
|
|
31
|
-
|
|
31
|
+
instance.interceptors.response.use(function (response) {
|
|
32
32
|
// 2xx 范围内的状态码都会触发该函数。
|
|
33
33
|
// 对响应数据做点什么
|
|
34
34
|
return response;
|
|
@@ -52,4 +52,3 @@ import { requestQueue } from "iota-fetch"
|
|
|
52
52
|
// abortive(key) map key取消请求的key
|
|
53
53
|
// removeResAll() 取消队列中所有的请求
|
|
54
54
|
```
|
|
55
|
-
|