
Security News
US Government Forces Anthropic to Pull Claude Fable Days After Launch
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.
easy-fetch-api
Advanced tools
Make REST requests using the Fetch API as easy as typing npm install and avoid having to manually handle headers and response parsing.
Easy to use and lightweight wrapper for the Fetch API.
Accept and Content-Type headers to application/json)This library does not provide a polyfill for the Fetch API.
npm install --save easy-fetch-api
import Api, { RESPONSE_TYPES } from 'easy-fetch-api';
Api.get({ url: '/api/me', callback: console.log });
await Api.post({ url: '/api/register', data: { email: 'value', password: 'value' } });
// Set headers on each request
Api.get({ url: '/api/me', headers: { Authorization: 'Bearer token' } });
// Or set headers globally and they are automatically passed on each request
Api.setHeaders({ Authorization: 'Bearer token' });
console.log(RESPONSE_TYPES) // { json: 'json', blob: 'blob', text: 'text' }
More detailed usage examples below in the docs of each method:
Set a base URL (if needed).
This will be used to prefix all later URLs
Api.setBaseUrl('https://api-domain.com');
Performs a HTTP Get request.
Api.get({
url: '/api/get',
headers: { Authorization: 'token' },
query: { q1: 'value', qn: 'value' },
responseType: Api.RESPONSE_TYPES.blob,
callback: () => {}
)};
{ headerKey: headerValue }{ queryKey: queryValue }Performs a HTTP Post request.
Api.post({
url: '/api/post',
data: { email: 'value', password: 'value' },
headers: { Authorization: 'token' },
callback: () => {}
)};
{ headerKey: headerValue }. Note that there are two preset heders: { Accept: 'application/json', 'Content-Type': 'application/json' }. You can override them using this parameterPerforms a HTTP Post request with form data.
Api.postForm({
url: '/api/postForm',
data: 'email=value&password=value',
headers: { Authorization: 'token' },
callback: () => {}
)};
{ headerKey: headerValue }. Note that there are two preset heders: { Accept: 'application/json', 'Content-Type': 'application/json' }. You can override them using this parameterPerforms a HTTP Put request.
Api.put({
url: `/api/put/${id}`,
data: { email: 'value', password: 'value' },
headers: { Authorization: 'token' },
callback: () => {}
)};
{ headerKey: headerValue }. Note that there are two preset heders: { Accept: 'application/json', 'Content-Type': 'application/json' }. You can override them using this parameterPerforms a HTTP Patch request.
Api.patch({
url: `/api/put/${id}`,
data: { email: 'value', password: 'value' },
headers: { Authorization: 'token' },
callback: () => {}
)};
{ headerKey: headerValue }. Note that there are two preset heders: { Accept: 'application/json', 'Content-Type': 'application/json' }. You can override them using this parameterPerforms a HTTP Delete request.
Api.delete({
url: '/api/delete',
headers: { Authorization: 'token' },
query: { q1: 'value', qn: 'value' },
callback: () => {}
)};
{ headerKey: headerValue }{ queryKey: queryValue }Functions to be called before the request is fired and after the server responds, respectively. Facilitates integration with store-based architectures like Redux.
Api.get({
url: '/api/get',
callBefore: () => { dispatch({ type: ACTIONS.LOADING }) },
callback: result => { dispatch({ type: ACTIONS.LOADING_DONE, data: result }) }
)};
The code is open-source and available under the MIT Licence. More details in the LICENCE.md file.
FAQs
Make REST requests using the Fetch API as easy as typing npm install and avoid having to manually handle headers and response parsing.
The npm package easy-fetch-api receives a total of 26 weekly downloads. As such, easy-fetch-api popularity was classified as not popular.
We found that easy-fetch-api 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
Anthropic says the directive cited national security concerns over a narrow jailbreak, but offered no specific technical details.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.