프로젝트
GitHub에서 보기
mlegenhausen/fetch-intercept
소개
Interceptor library for the native fetch command inspired by angular http intercepts.
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalfetch-intercept
Interceptor library for the native fetch command inspired by angular http interceptors.
fetch-intercept monkey patches the global fetch method and allows you the usage in Browser, Node and Webworker environments.
Installation
npm install fetch-intercept --save
Usage
Note: You need to require fetch-intercept before you use fetch the first time.
Make sure you have a fetch compatible environment or added a appropriate polyfill.
import fetchIntercept from 'fetch-intercept';
const unregister = fetchIntercept.register({
request: function (url, config) {
// Modify the url or config here
return [url, config];
},
requestError: function (error) {
// Called when an error occured during another 'request' interceptor call
return Promise.reject(error);
},
response: function (response) {
// Modify the reponse object
return response;
},
responseError: function (error) {
// Handle an fetch error
return Promise.reject(error);
}
});
// Call fetch to see your interceptors in action.
fetch('http://google.com');
// Unregister your interceptor
unregister();
React-Native Compatibility
Support react-native 0.17 or higher versions.
License
MIT
관련 프로젝트 살펴보기
불러오는 중…