Gathering detailed insights and metrics for fetch-polyfill2
Gathering detailed insights and metrics for fetch-polyfill2
Gathering detailed insights and metrics for fetch-polyfill2
Gathering detailed insights and metrics for fetch-polyfill2
fetch polyfill which supports all mainstream browsers, even IE6, IE7, IE8.....
npm install fetch-polyfill2
Typescript
Module System
Node Version
NPM Version
JavaScript (88.2%)
HTML (11.8%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
150 Stars
15 Commits
20 Forks
7 Watchers
1 Branches
1 Contributors
Updated on Oct 29, 2023
Latest Version
0.0.3
Package Id
fetch-polyfill2@0.0.3
Size
218.99 kB
NPM Version
3.5.3
Node Version
4.1.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
1
fetch polyfill which supports all mainstream browsers, even IE6, IE7, IE8.....
$ npm install fetch-polyfill2 --save
$ npm install bluebird -- save
$ npm install json3 -- save
1fetch('/users.html') 2 .then(function(response) { 3 return response.text() 4 }).then(function(body) { 5 document.body.innerHTML = body 6 })
1fetch('/users.json') 2 .then(function(response) { 3 return response.json() 4 }).then(function(json) { 5 console.log('parsed json', json) 6 }).catch(function(ex) { 7 console.log('parsing failed', ex) 8 })
1fetch('/users.json').then(function(response) { 2 console.log(response.headers.get('Content-Type')) 3 console.log(response.headers.get('Date')) 4 console.log(response.status) 5 console.log(response.statusText) 6})
1var form = document.querySelector('form') 2 3fetch('/users', { 4 method: 'POST', 5 body: new FormData(form) 6})
1fetch('/users', { 2 method: 'POST', 3 headers: { 4 'Accept': 'application/json', 5 'Content-Type': 'application/json' 6 }, 7 body: JSON.stringify({ 8 name: 'Hubot', 9 login: 'hubot', 10 }) 11})
1var input = document.querySelector('input[type="file"]') 2 3var data = new FormData() 4data.append('file', input.files[0]) 5data.append('user', 'hubot') 6 7fetch('/avatars', { 8 method: 'POST', 9 body: data 10})
###IE6-7 cors
涉及到的参数
jsonpCallbackFunction : 后端生成的函数名, 不传自动生成,与jQuery一致
jsonpCallback: 链接中的名字,不传为callback
,与jQuery一致
charset: 设置script的字符集
所有情况下,想跨域,都需要手动设置 credentials: 'include' 所有情况下,如果想发送请求,想带着cookie, 都需要设置 credentials: 'include'
1fetch('/users', { //jsonp!!! 2 credentials: 'include', 3}).then(function(response){ 4 return response.json() 5}).then(function(){ 6 7})
###使用fetch下载HTML乱码问题
fetch('http://tieba.baidu.com')
.then(res=> res.blob())
.then(blob => {
var reader = new FileReader();
reader.onload = function(e) {
var text = reader.result;
console.log(text)
}
reader.readAsText(blob, 'GBK') //或 UTF8,逐个试
})
更多用法见这里 http://www.w3ctech.com/topic/854
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/15 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
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