
Research
/Security News
Miasma Mini Shai-Hulud Hits ImmobiliareLabs npm Packages
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.
fetch-default
Advanced tools
npm i fetch-default --save
require('fetch-default');
//es
import 'fetch-default';
fetch.default({
method: 'GET',
headers: myHeaders,
mode: 'cors',
cache: 'default'
...
});
/*
//default
method: 'GET',
headers: myHeaders,
mode: 'cors',
cache: 'default'
...
*/
fetch('/async/get', {
method: 'POST'//covering to post
})
.then((response) => response.json())
.then((json) => console.log(json));
fetch.default({
beforeSend() {
if(example)this.uri=this.uri+'/example';
}
});
fetch.default({
dataFilter(response) {
if (!response.ok) {
//if you use fetch-abort (https://www.npmjs.com/package/fetch-abort)
this.abort()
message.error(`${response.status}\n${response.statusText}`);
}
return response.json();
}
});
fetch.default({
fail(e) {
//if you use fetch-abort (https://www.npmjs.com/package/fetch-abort)
this.abort()
message.error(e.toString());
}
});
fetch.default({
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': ' application/json',
},
credentials: 'include',
beforeSend() {
//excludes serviceWorker
if (!/http:\/\//.test(this.uri)&&process.env.HOME_PAGE) this.uri = `${process.env.FETCH_PREFIX}${this.uri}`;
},
async dataFilter(response) {
//excludes serviceWorker request flies
if(!/^((ht|f)tps?):\/\/[\s\S]+\/[\s\S]+\.[\s\S]+$/.test(response.url)){
if (response.ok===false) {
message.error(`${response.status}\n${response.statusText}`);
return {}
}
let data = await response.json();
let {code,message:messageDes,messageBody} = data;
//not login
// if(code === 5000){
// message.error(messageDes);
// store.dispatch(actiontor.loginFlag(false));
// }
if(code !== '9000'){
message.error(messageDes);
}
return data;
}else{
return response
}
},
fail(e) {
message.error(e.toString());
return e
}
});
FAQs
Add global default properties for the web fetch
The npm package fetch-default receives a total of 88 weekly downloads. As such, fetch-default popularity was classified as not popular.
We found that fetch-default demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Miasma Mini Shai-Hulud hits @immobiliarelabs Backstage plugins, targeting GitLab and LDAP auth packages on npm.

Security News
Rolldown paused Rust React Compiler integration after a 5MB binary size increase raised concerns about shipping React-specific code to all Vite users.

Security News
/Research
Mini Shai-Hulud expands into the Go ecosystem after hitting LeoPlatform npm packages and targeting GitHub Actions workflows.