Bhupendra
Bhupendra

Reputation: 1286

Issue in accessing Bing Custom Web Search API v7

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

enter image description here

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

Upvotes: 1

Views: 1001

Answers (0)

Related Questions