-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbing_api.js
More file actions
25 lines (22 loc) · 747 Bytes
/
bing_api.js
File metadata and controls
25 lines (22 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'use strict';
let https = require('https');
let subscriptionKey = 'enter key here';
let host = 'api.cognitive.microsoft.com';
let path = '/bing/v7.0/news/search';
let term = 'Microsoft';
let response_handler = function (response) {
let body = '';
};
response.on('data', function (d) {
body += d;
});
response.on('end', function () {
console.log('\nRelevant Headers:\n');
for (var header in response.headers)
// header keys are lower-cased by Node.js
if (header.startsWith("bingapis-") || header.startsWith("x-msedge-"))
console.log(header + ": " + response.headers[header]);
body = JSON.stringify(JSON.parse(body), null, ' ');
console.log('\nJSON Response:\n');
console.log(body);
});