Gathering detailed insights and metrics for easy-fetch-api
Gathering detailed insights and metrics for easy-fetch-api
Gathering detailed insights and metrics for easy-fetch-api
Gathering detailed insights and metrics for easy-fetch-api
fetch-sse
An easy API for making Event Source requests, with all the features of fetch(), Supports browsers and node.
fetch-wordpress-api
Easy fetching from the Wordpress API
@umijs/fetch-sse
An easy API for making Event Source requests, with all the features of fetch(), Supports browsers and nodejs.
@ambassify/fetch-api
Small class to create easy to use API clients with fetch
npm install easy-fetch-api
Typescript
Module System
Node Version
NPM Version
71.9
Supply Chain
98.9
Quality
75.9
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
14,570
Last Day
3
Last Week
39
Last Month
127
Last Year
2,706
2 Stars
59 Commits
1 Forks
2 Watching
17 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
2.7.1
Package Id
easy-fetch-api@2.7.1
Unpacked Size
31.09 kB
Size
6.18 kB
File Count
7
NPM Version
8.15.0
Node Version
16.17.0
Publised On
15 May 2023
Cumulative downloads
Total Downloads
Last day
50%
3
Compared to previous day
Last week
30%
39
Compared to previous week
Last month
3.3%
127
Compared to previous month
Last year
-5.4%
2,706
Compared to previous year
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.
1npm install --save easy-fetch-api
1import Api, { RESPONSE_TYPES } from 'easy-fetch-api'; 2 3Api.get({ url: '/api/me', callback: console.log }); 4 5await Api.post({ url: '/api/register', data: { email: 'value', password: 'value' } }); 6 7// Set headers on each request 8Api.get({ url: '/api/me', headers: { Authorization: 'Bearer token' } }); 9 10// Or set headers globally and they are automatically passed on each request 11Api.setHeaders({ Authorization: 'Bearer token' }); 12 13console.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
1Api.setBaseUrl('https://api-domain.com');
Performs a HTTP Get request.
1Api.get({ 2 url: '/api/get', 3 headers: { Authorization: 'token' }, 4 query: { q1: 'value', qn: 'value' }, 5 responseType: Api.RESPONSE_TYPES.blob, 6 callback: () => {} 7)};
{ headerKey: headerValue }
{ queryKey: queryValue }
Performs a HTTP Post request.
1Api.post({ 2 url: '/api/post', 3 data: { email: 'value', password: 'value' }, 4 headers: { Authorization: 'token' }, 5 callback: () => {} 6)};
{ 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.
1Api.postForm({ 2 url: '/api/postForm', 3 data: 'email=value&password=value', 4 headers: { Authorization: 'token' }, 5 callback: () => {} 6)};
{ 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.
1Api.put({ 2 url: `/api/put/${id}`, 3 data: { email: 'value', password: 'value' }, 4 headers: { Authorization: 'token' }, 5 callback: () => {} 6)};
{ 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.
1Api.patch({ 2 url: `/api/put/${id}`, 3 data: { email: 'value', password: 'value' }, 4 headers: { Authorization: 'token' }, 5 callback: () => {} 6)};
{ 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.
1Api.delete({ 2 url: '/api/delete', 3 headers: { Authorization: 'token' }, 4 query: { q1: 'value', qn: 'value' }, 5 callback: () => {} 6)};
{ 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.
1Api.get({ 2 url: '/api/get', 3 callBefore: () => { dispatch({ type: ACTIONS.LOADING }) }, 4 callback: result => { dispatch({ type: ACTIONS.LOADING_DONE, data: result }) } 5)};
The code is open-source and available under the MIT Licence. More details in the LICENCE.md file.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/21 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
56 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-20
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More