1.3.8 • Published 6 years ago
simple-fetch-wrapper v1.3.8
Simple Fetch Wrapper
Simple wrapper around fetch.
For own purposes initially...
GET and POST
Use
npm i simple-fetch-wrapperimport http from 'simple-fetch-wrapper'API Examples
import http from 'simple-fetch-wrapper'
http.setBaseUrl(url: string);
http.setDefaultContentType('application/json');
const url = http.getBaseUrl('/api/v1/endpoint');
http.interceptor(requestConfig => {
console.log(requestConfig);
requestConfig.headers.append('Authorization', `Bearer ${token}`);
return requestConfig;
})
http.isFetching(status: boolean) => console.log(status));
http.on('customEvent', (data) => console.log(data));
http.emit('customEvent', data);
http.detach('customEvent', Function);Supports GET and POST
const args = {
params: {post: 71}
};
const response = await http.get(url, args)
const args = {
headers: {'Content-Type': 'application/json'},
body: {name: 'Some name', id: 1}
};
const response = await http.post(url, args);Args
| Properties | Type |
|---|---|
| headers | {key: string: string} |
| body | {key: string: any} |
| params | {key: string: any} |
1.3.7
6 years ago
1.3.6
6 years ago
1.3.8
6 years ago
1.3.5
6 years ago
1.3.4
6 years ago
1.3.3
6 years ago
1.3.2
6 years ago
1.3.0
6 years ago
1.1.5
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.1
6 years ago
1.1.2
6 years ago
1.1.0
6 years ago
1.0.17
6 years ago
1.0.16
6 years ago
1.0.15
6 years ago
1.0.14
6 years ago
1.0.11
6 years ago
1.0.10
6 years ago
1.0.13
6 years ago
1.0.9
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago