medmond919 icon

Single API Client

medmond919 | PRO | 04/20/16 07:06:33 PM UTC | 0 ⭐ | 397 👁️ | Never ⏰ | []
text |

650 B

|

None

|

0 👍

/

0 👎

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