buddy

node MVC discord bot
Log | Files | Refs | README

node-request.js (409B)


      1 const https = require('https');
      2 
      3 module.exports = function(url){
      4   return new Promise(( resolve ,reject )=>{
      5      https.get(url,
      6       (res) => {
      7         let data = '';
      8         res.on('data', (chunk) => {
      9           data += chunk;
     10         });
     11          res.on('end', () => {
     12            resolve(JSON.parse(data));
     13         });
     14       }).on('error', (err) => {
     15          reject(JSON.parse(err));
     16       });
     17     });
     18 }