var request = require('request');
//Read the API Key
...
}
function getSyn(word, callback) {
var options = {
uri : ' http://words.exampleapi.com/api/2/' + config.apiKey + '/' + blah blah + '/json ',
method : 'GET'
};
var res = '';
request(options, function (error, response, body) {
if (!error && response.statusCode == 200) {
res = body;
}
else {
res = 'Not Found';
}
callback(res);
});
}
getSyn("motivation", function(resp){
var parsed = JSON.parse(resp);
console.log(parsed.noun.syn[0]);
console.log(parsed);
});
Comments