Merge pull request #4 from camilokorea/master
fixing communication with xeno-canto api using REQUEST lib
This commit is contained in:
commit
5046544853
@ -9,7 +9,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** @dependencies */
|
/** @dependencies */
|
||||||
var rest = require('rest');
|
var request = require('request');
|
||||||
|
|
||||||
/** @constructor */
|
/** @constructor */
|
||||||
function XenoCanto(){
|
function XenoCanto(){
|
||||||
@ -93,12 +93,23 @@ XenoCanto.prototype.search = function(query, success){
|
|||||||
};
|
};
|
||||||
|
|
||||||
function get(that, url, success){
|
function get(that, url, success){
|
||||||
rest(url).then(function(response) {
|
|
||||||
// store response in instance var
|
var opts = {
|
||||||
that.entity = JSON.parse(response.entity);
|
url: url,
|
||||||
success(that);
|
method: 'GET',
|
||||||
|
timeout: (10*1000),
|
||||||
|
headers:
|
||||||
|
{
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163 Safari/537.36'
|
||||||
}
|
}
|
||||||
);
|
};
|
||||||
|
|
||||||
|
request(opts, function (err, res, url) {
|
||||||
|
// store response in instance var
|
||||||
|
that.entity = JSON.parse(res.body);
|
||||||
|
success(that);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user