silvrgit/lib/today/quotes.js

41 lines
965 B
JavaScript
Raw Normal View History

2016-10-23 22:52:59 +00:00
/**
* Created by Martin on 31/03/2016.
*/
const https = require('https');
2016-10-23 22:52:59 +00:00
const STRING = require('string');
const logger = require('log4js').getLogger('quotes');
2016-10-23 22:52:59 +00:00
const 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'
2016-10-23 22:52:59 +00:00
},
'method': 'GET'
};
2016-10-23 22:52:59 +00:00
module.exports = {
'GetQuotes': function() {
'use strict';
return new Promise(function(resolve, reject) {
https.request(options).on('response', function (response) {
let data = '';
response.on('data', function (chunk) {
data += chunk;
2016-10-23 22:52:59 +00:00
});
response.on('end', function () {
// console.log(data);
// callback(JSON.parse(data));
resolve(JSON.parse(data));
});
}).end();
});
}
2016-10-23 22:52:59 +00:00
};