我正在尝试访问 Bing 自定义搜索API。自定义搜索实例已设置并能够从 BING 门户(生产选项卡)调用 API,但是当我尝试通过 JS 访问相同的 URL 时。我收到失败的请求,如下所示
以下是我访问 API 的方式:
const query = "app";
const url = `https://api.bing.microsoft.com/v7.0/custom/search?q=${query}&customconfig=<CUSTOM_CONFIG_ID>&mkt=zh-CN`;
const option = {
mode: "cors",
headers: {
"Ocp-Apim-Subscription-Key": <Subsription Key>
}
};
fetch(url, option)
.then((res) => res.json())
.then((data) => console.log(data))
.catch((err) => console.log(err));
我收到错误
类型错误:获取失败