首页 > fetch跨域调用第三方API获取数据时要怎么设置

fetch跨域调用第三方API获取数据时要怎么设置

如题,代码如下:

const URL = 'http://api.xx.com/?q='
let req = URL + word
fetch(req)
    .then(res => res.json())
    .then(res => console.log(res)
    .catch(err => console.log(err)

在本地调试的时候,由于跨域不能访问,请问跨域的情况下该如何使用fetch


你的http://api.xx.com/?q=返回header里有正确设置Access-Control-Allow-Origin吗?

【热门文章】
【热门文章】