Gathering detailed insights and metrics for unfetch-pinkie
Gathering detailed insights and metrics for unfetch-pinkie
Gathering detailed insights and metrics for unfetch-pinkie
Gathering detailed insights and metrics for unfetch-pinkie
npm install unfetch-pinkie
Typescript
Module System
Node Version
NPM Version
JavaScript (86.19%)
TypeScript (13.81%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
5,718 Stars
229 Commits
202 Forks
40 Watchers
2 Branches
35 Contributors
Updated on Jul 10, 2025
Latest Version
2.1.2
Package Id
unfetch-pinkie@2.1.2
Size
6.26 kB
NPM Version
3.10.8
Node Version
7.7.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Tiny 500b fetch "barely-polyfill"
fetch()
with headers and text/json/xml responsesPromise
is polyfilled of course!)🤔 What's Missing?
- Uses simple Arrays instead of Iterables, since Arrays are iterables
- No streaming, just Promisifies existing XMLHttpRequest response bodies
This project uses node and npm. Go check them out if you don't have them locally installed.
1$ npm install --save unfetch
Then with a module bundler like rollup or webpack, use as you would anything else:
1// using ES6 modules 2import fetch from 'unfetch' 3 4// using CommonJS modules 5var fetch = require('unfetch')
The UMD build is also available on unpkg:
1<script src="//unpkg.com/unfetch/dist/unfetch.umd.js"></script>
This exposes the unfetch()
function as a global.
As a ponyfill:
1import fetch from 'unfetch'; 2 3fetch('/foo.json') 4 .then( r => r.json() ) 5 .then( data => { 6 console.log(data); 7 });
Globally, as a polyfill:
1import 'unfetch/polyfill'; 2 3// "fetch" is now installed globally if it wasn't already available 4 5fetch('/foo.json') 6 .then( r => r.json() ) 7 .then( data => { 8 console.log(data); 9 });
1// simple GET request: 2fetch('/foo') 3 .then( r => r.text() ) 4 .then( txt => console.log(txt) ) 5 6 7// complex POST request with JSON, headers: 8fetch('/bear', { 9 method: 'POST', 10 headers: { 11 'Content-Type': 'application/json' 12 }, 13 body: JSON.stringify({ hungry: true }) 14}).then( r => { 15 open(r.headers.get('location')); 16 return r.json(); 17})
Adapted from the GitHub fetch polyfill readme.
The fetch
specification differs from jQuery.ajax()
in mainly two ways that
bear keeping in mind:
fetch
won't send or receive any cookies from the server,
resulting in unauthenticated requests if the site relies on maintaining a user
session.1fetch('/users', { 2 credentials: 'include' 3});
The Promise returned from fetch()
won't reject on HTTP error status
even if the response is an HTTP 404 or 500. Instead, it will resolve normally,
and it will only reject on network failure or if anything prevented the
request from completing.
To have fetch
Promise reject on HTTP error statuses, i.e. on any non-2xx
status, define a custom response handler:
1fetch('/users') 2 .then( checkStatus ) 3 .then( r => r.json() ) 4 .then( data => { 5 console.log(data); 6 }); 7 8function checkStatus(response) { 9 if (response.ok) { 10 return response; 11 } else { 12 var error = new Error(response.statusText); 13 error.response = response; 14 return Promise.reject(error); 15 } 16}
First off, thanks for taking the time to contribute! Now, take a moment to be sure your contributions make sense to everyone else.
Found a problem? Want a new feature? First of all see if your issue or idea has already been reported. If it hasn't, just open a new clear and descriptive issue.
Pull requests are the greatest contributions, so be sure they are focused in scope, and do avoid unrelated commits.
💁 Remember: size is the #1 priority.
Every byte counts! PR's can't be merged if they increase the output size much.
git clone https://github.com/<your-username>/unfetch
cd unfetch
git checkout -b my-new-feature
npm install
npm run build
to verify your change doesn't increase output size.npm test
to make sure your change doesn't break anything.git commit -am 'Add some feature'
git push origin my-new-feature
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 6/20 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
15 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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