2.0.0-alpha6 • Published 2 years ago
@emravoan/konfetch v2.0.0-alpha6
Example
import KonFetch from '@emravoan/konfetch';
const params = { search: 'foobar', page: 1 };
const header = { 'X-Custom-Header': 'foobar' };
KonFetch.get('https://some-domain.com/api', header, params, { isShowLoading: true })
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Usage
Initialize
// ES6 Modules or TypeScript
import KonFetch from '@emravoan/konfetch';
// CommonJS
const KonFetch = require('@emravoan/konfetch');
Methods
KonFetch.get(url, header, params, options);
KonFetch.delete(url, header, data, options);
KonFetch.post(url, header, data, options);
KonFetch.put(url, header, data, options);
Config
// `url` is the server URL that will be used for the request
url: 'https://some-domain.com/api',
// `headers` are custom headers to be sent
headers: {'X-Requested-With': 'XMLHttpRequest'},
// `params` are the URL parameters to be sent with the request
// Must be a plain object or a URLSearchParams object
// NOTE: params that are null or undefined are not rendered in the URL.
params: {
search: 'foobar'
},
// `data` is the data to be sent as the request body
// Only applicable for request methods 'PUT', 'POST' and 'DELETE'
// Must be a plain object or a FormData
data: {
name: 'Foo Bar'
},
// `options` is the setting
// - isShowLoading: show loading while request to server
// - isReloadOnError: reload the page if request is error
// - isReloadOnError: reload the page if request is successful
options: {
isShowLoading: true // default
isReloadOnError: false // default
isReloadOnSuccess: false // default
},
2.0.0-alpha6
2 years ago
2.0.0-alpha5
2 years ago
2.0.0-alpha4
2 years ago
2.0.0-alpha3
3 years ago
2.0.0-alpha2
3 years ago
2.0.0-alpha1
3 years ago
1.0.5-beta6
3 years ago
1.0.5-beta5
3 years ago
1.0.5-beta4
3 years ago
1.0.5-beta3
3 years ago
1.0.5-beta2
3 years ago
1.0.5-beta.1
3 years ago
1.0.5-beta.0
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago