
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
fake-browser-fetch
Advanced tools
If you hate spinning up a web server everytime you are building a small pet project or demo project then this is for you 🎉
npm i --dev fake-browser-fetch
import fakeFetch from 'fake-browser-fetch';
...
if(process.env.NODE_ENV === 'development') {
fakeFetch([{
request: '/api/users/ameerthehacker',
response: new Response(JSON.stringify({ name: "Ameer Jhan" })),
// delay in milliseconds
delay: 3000
}]);
}
...
// will print { name: "Ameer Jhan" } after 3s
fetch('/api/users/ameerthehacker')
.then(res => res.json())
.then(user => console.log(user));
fakeFetch([
{
request: new Request('/api/users/create', {
method: 'POST',
body: JSON.stringify({
name: 'Ameer Jhan',
username: 'ameerthehacker'
})
}),
response: new Response(JSON.stringify({ done: true }))
}
]);
fakeFetch([
{
request: new Request('/api/add', {
method: 'POST',
body: JSON.stringify({ name: 'Ameer' })
}),
response: async (request) => {
const body = await request.json();
return new Response(body.name.toLowerCase());
}
}
]);
fetch(`/api/add`, {
body: JSON.stringify({ name: 'Ameer' })
})
.then((res) => res.text())
// this will print `ameer`
.then((res) => console.log(res));
const error = new Error('ETIMEOUT: the server timedout');
fakeFetch([
{
request: '/api/users',
error
}
]);
// this promise will get reject with `error`
fetch('/api/users').catch((err) => console.log(err));
fakeFetch({
globalConfig: {
delay: 3000
},
fakeConfigs: [
{
request: '/api/users/ameerthehacker',
response: new Response(JSON.stringify({ name: 'Ameer Jhan' })),
// local delay are given higher precedence
delay: 5000
}
]
});
If fakeFetch could not find any fake config for a given request then it will return a default 404 response, you can also customize it as shown below
const _404Response = new Response(undefined, {
status: 404,
statusText: 'User defined 404 response'
});
fakeFetch({
globalConfig: {
_404Response
},
fakeConfigs: [...]
});
Show your support by ⭐️ the repo
MIT © Ameer Jhan
FAQs
Fake fetch responses in browser
We found that fake-browser-fetch 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.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.