Quick follow-up on your second question. Users can only pass Market as a query parameter to get results only from that market, and can get market used by the API request as BingAPIs-Market Header. Please refer to the following documents (response objects, headers) for more details. Hope this helps!
How to get BingAPIs-Market response header
Venkatesh Gottimukkula (INFOSYS LIMITED)
1
Reputation point
We have a scenario where we need to show the Bing Market/ Region from where the Bing news is being fetched. In the response headers, I am able to see BingAPIs-Market.
- I am getting empty object as response headers. Do we need to add any request headers to get response headers
- Is there any API to fetch BingAPIs-Market response header
2 answers
Sort by: Newest
-
-
GiftA-MSFT 11,151 Reputation points
2021-04-27T20:35:50.303+00:00 Here's a sample code to fetch the headers. Hope this helps.
const fetch = require("node-fetch"); var myHeaders = new fetch.Headers(); myHeaders.append("Ocp-Apim-Subscription-Key", "ENTER YOUR KEY"); var requestOptions = { method: 'GET', headers: myHeaders, redirect: 'follow' }; // search results fetch("https://api.bing.microsoft.com/v7.0/news/search?q=microsoft", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error)); // response headers fetch("https://api.bing.microsoft.com/v7.0/news/search?q=microsoft", requestOptions) .then(response => response.headers) .then(result => console.log(result)) .catch(error => console.log('error', error)); // BingAPIs-Market fetch("https://api.bing.microsoft.com/v7.0/news/search?q=microsoft", requestOptions) .then(response => response.headers.get('bingapis-market')) .then(result => console.log(result)) .catch(error => console.log('error', error));