I am trying to access the Bing Custom Search API. Custom Search Instance is setup and able to call API from BING portal (production tab), however when I am trying to access the same URL through JS. I am getting Failed Request as below
Below is the way I am accessing the 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));
I am getting error
TypeError: Failed to fetch
Find
CUSTOM_CONFIG_ID
in https://www.customsearch.ai/ .Find
Ocp-Apim-Subscription-Key
on portal.My Test Result:
Please run
node install node-fetch
first.