UNPKG

datacache-request

Version:

Module provides indexing and access to datacache service functions

31 lines (22 loc) 736 B
'use strict'; const unirest = require('unirest'); class RapidAPIRequest { constructor(url, api_key) { this.url = url; this.key = api_key; } exec(endpoint, data) { return new Promise((resolve, reject) => { unirest.post(this.url + "/" + endpoint) .header("X-Mashape-Key", this.key) .header("Content-Type", "application/json") .header("Accept", "application/json") .send(data) .end(function (result) { //console.log(result.status, result.headers, result.body); resolve(result.body.data); }); }); } }; module.exports = RapidAPIRequest;