黑白梦黑白梦

toggle navtoggle nav
  • 文章
  • 专栏
  • 文章
  • 专栏

fetch-jsonp 跨域 jsonp 请求

发布于 2020-04-09, 更新于 2023-04-08

类似 window.fetch 的 JSONP 请求库

https://github.com/camsong/fetch-jsonp

npm install fetch-jsonp

根据接口返回callback函数名,指定即可使用

fetchJsonp('/users.jsonp', {
    jsonpCallback: 'custom_callback',
  })
  .then(function(response) {
    return response.json()
  }).then(function(json) {
    console.log('parsed json', json)
  }).catch(function(ex) {
    console.log('parsing failed', ex)
  })
本文收录于专栏

一些好用的 npm 前端开源库

收集一些好用的前端开源库,主要是 npm 包

©2015-2026 黑白梦 粤ICP备15018165号

联系: heibaimeng@foxmail.com