支持 jsonp 的Fetch polyfill fetch-jsonp-polyfill

码农软件 · 软件分类 · 其他开发相关 · 2019-10-16 18:56:37

软件介绍

fetch-jsonp-polyfill 是对原生 Fetch API 的扩展,使之支持 jsonp。

下载地址 https://github.com/fetch-extras/fetch-jsonp-polyfill

 

几乎所有主流的 jsonp polyfill 库兼容,如https://github.com/github/fetchhttps://github.com/matthew-andrews/isomorphic-fetch 、https://github.com/bitinn/node-fetch

安装

使用 npm

npm install fetch-jsonp-polyfill --save-dev

 

引用

require('isomorphic-fetch')
require('fetch-jsonp-polyfill')

or 
import 'whatwg-fetch'
import 'fetch-jsonp-polyfill'

 

使用

fetch('http://jsfiddle.net/echo/jsonp/?hello=world', {
    method: "JSONP"
})
.then(res => res.json())
.then(data => {
    console.log(data);
})
.catch(err => {
    console.log(err);
})

 

其它选项

fetch(URL, {
    method: 'JSONP',
    timeout: 5000,
    callback: 'callback',
    callbackName: 'fetchjsonp_callback',
})

 

浏览器支持

Chrome Firefox IE Opera Safari
Latest ✔ Latest ✔ 9+ ✔ Latest ✔ 6.1+ ✔

本文地址:https://www.codercto.com/soft/d/16904.html

电商运营之道:策略、方法与实践

电商运营之道:策略、方法与实践

吴伟定、姚金刚、周振兴、郑琰 / 机械工业出版社 / 2015-9-1 / 49

电商运营之道:策略、方法与实践是一本电商的运营指南,适合所有的电商从业人员阅读,也适合打算进入或打算在电商行业创业的读者朋友阅读。分别从策略、方法与实践三个方面全景式展示电商运营的内在商业规律与管理逻辑。一起来看看 《电商运营之道:策略、方法与实践》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具