/** * Created by Martin on 31/03/2016. */ var https = require('https'); var STRING = require('string'); var logger = require('log4js').getLogger(); var options = { host: 'andruxnet-random-famous-quotes.p.mashape.com', path: '/?cat=famous', headers: { accept: "application/json", "X-Mashape-Key": "5A0H980jK6mshSFL24ZmfiRrNHV2p1d1fhQjsngtx8QWuO9oe4", 'Content-Type': "application/x-www-form-urlencoded" }, method: 'GET' }; module.exports = { GetQuotes: function() { 'use strict'; return new Promise(function(resolve, reject) { https.request(options).on('response', function (response) { var data = ''; response.on("data", function (chunk) { data += chunk; }); response.on('end', function () { //console.log(data); //callback(JSON.parse(data)); resolve(JSON.parse(data)); }); }).end(); }); } };