api.instagram CORB网络错误,原因是具有Content-Type:application / json`的jsonp响应标头

Gus*_*avo 2 instagram-api

我正在使用fetch-jsonp进行抓取,https://api.instagram.com/oembed/?url=<embedUrl>以使用response.html嵌入到我的网站中。

但是我的请求出现CORB错误时遇到了问题。

这是我的代码片段:

fetchJsonp("https://api.instagram.com/oembed/?url=" + url, {
  timeout: 800,
}).then(function(response) {
  return response.json();
})
Run Code Online (Sandbox Code Playgroud)

我的控制台:

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.instagram.com/oembed/?url=<embedUrl> with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Run Code Online (Sandbox Code Playgroud)

我通过相同的代码访问来处理来自twitter的嵌入,https://api.twitter.com/1/statuses/oembed.json?url=<embedUrl>并且效果很好。

由于twitter响应具有a的Content-Type: application/javascript作用,而instagram响应具有a的作用Content-Type: application/json却不起作用。

我该如何进行这项工作?

小智 5

我们有同样的问题,但是从jsonp切换到json可以解决问题。例如:

fetch("https://api.instagram.com/oembed/?url=" + url)
  .then(function(response){
    return response.json()
  })
  .then(function(json){
    console.log(json)
  })
Run Code Online (Sandbox Code Playgroud)