Support for Markets
This commit is contained in:
parent
d4f6a404d9
commit
765c9438d5
1 changed files with 11 additions and 5 deletions
16
lib/bing.js
16
lib/bing.js
|
@ -61,7 +61,8 @@ var Bing = function( options ) {
|
||||||
+ "?$format=json&"
|
+ "?$format=json&"
|
||||||
+ qs.stringify({ "Query": "'" + query + "'" })
|
+ qs.stringify({ "Query": "'" + query + "'" })
|
||||||
+ "&$top=" + opts.top
|
+ "&$top=" + opts.top
|
||||||
+ "&$skip=" + opts.skip;
|
+ "&$skip=" + opts.skip
|
||||||
|
+ (opts.market ? "&Market=%27" + opts.market + "%27" : '');
|
||||||
|
|
||||||
request({
|
request({
|
||||||
uri: reqUri,
|
uri: reqUri,
|
||||||
|
@ -77,10 +78,15 @@ var Bing = function( options ) {
|
||||||
|
|
||||||
}, function(err, res, body){
|
}, function(err, res, body){
|
||||||
|
|
||||||
// Parse body, if body
|
if(res.statusCode !== 200){
|
||||||
body = typeof body === 'string'
|
err = new Error(body);
|
||||||
? JSON.parse(body)
|
}else{
|
||||||
: body;
|
|
||||||
|
// Parse body, if body
|
||||||
|
body = typeof body === 'string'
|
||||||
|
? JSON.parse(body)
|
||||||
|
: body;
|
||||||
|
}
|
||||||
|
|
||||||
callback(err, res, body);
|
callback(err, res, body);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue