1.3.8 • Published 5 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-wrapper
import 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
5 years ago
1.3.6
5 years ago
1.3.8
5 years ago
1.3.5
5 years ago
1.3.4
5 years ago
1.3.3
5 years ago
1.3.2
5 years ago
1.3.0
5 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.1
5 years ago
1.1.2
5 years ago
1.1.0
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.13
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago