Skip to content

Commit 168ed62

Browse files
committed
updating node js quickstart
1 parent d97c390 commit 168ed62

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
//Copyright (c) Microsoft Corporation. All rights reserved.
22
//Licensed under the MIT License.
3-
3+
// <vars>
44
var request = require("request");
5-
6-
var subscriptionKey = process.env['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY']
7-
var customConfigId = 'YOUR-CUSTOM-CONFIG-ID';
5+
// Add your Bing Custom Search subscription key to your environment variables.
6+
// Your endpoint will have the form:
7+
// https://<your-custom-subdomain>.cognitiveservices.azure.com/bingcustomsearch/v7.0
8+
var subscriptionKey = process.env['BING_CUSTOM_SEARCH_SUBSCRIPTION_KEY'];
9+
var endpoint = process.env['BING_CUSTOM_SEARCH_ENDPOINT'];
10+
var customConfigId = 'YOUR-CUSTOM-CONFIG-ID'; //you can also use "1"
811
var searchTerm = 'microsoft';
9-
12+
// </vars>
13+
// <requestOptions>
1014
var options = {
11-
url: process.env['BING_CUSTOM_SEARCH_ENDPOINT'] + "/bingcustomsearch/v7.0/search?' +
15+
url: endpoint + "/search?" +
1216
'q=' + searchTerm +
1317
'&customconfig=' + customConfigId,
1418
headers: {
1519
'Ocp-Apim-Subscription-Key' : subscriptionKey
1620
}
1721
}
18-
22+
// </requestOptions>
23+
// <requestMethod>
1924
request(options, function(error, response, body){
2025
var searchResponse = JSON.parse(body);
2126
for(var i = 0; i < searchResponse.webPages.value.length; ++i){
@@ -28,3 +33,4 @@ request(options, function(error, response, body){
2833
console.log();
2934
}
3035
})
36+
// </requestMethod>

0 commit comments

Comments
 (0)