msb-fetch
v1.0.8
Published
for api call
Downloads
6
Maintainers
Readme
msb-fectch
Example code
use
import MsbFetch from "msb-fetch";
let data1 = await MsbFetch.get(`your url`);
console.log(data1);
let data2=await MsbFetch.post('your url', { params1: 'params1' });
MsbFetch.post('your url', { params1: 'params1' }).then((data) => {
console.log(data);
})
const fd = new FormData();
fd.append('params1', 'params1');
MsbFetch.post('your url', fd, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}).then((data) => {
console.log(data);
})
const request=await MsbFetch.multipleGet(['url1','url2','url2'])
const request2 = await MsbFetch.multipleRequest([{ url: 'uri1', method: 'GET',body:{} },{ url: 'url2', method: 'GET',body:{params:'params'} }]);
const onUploadProgress = (progress: number) => {
console.log(`Upload Progress: ${progress}%`);
};
const fd=new FormData();
fd.append('key','value');
// add FormData
const request = await MsbFetch.post('your url', fd, { onUploadProgress: onUploadProgress });
const onUploadKeyProgress = (progressMap: ProgressMap[]) => {
console.log(progressMap)
}
const fd=new FormData();
fd.append('key','value');
// add FormData
const request = await MsbFetch.manyFileUpload('http://127.0.0.1:8000/api/uploads', fd, { onUploadKeyProgress: onUploadKeyProgress });
npm Install
npm i msb-fetch
yarn Install
yarn add msb-fetch