tpgRequest.js (view raw)
1const config = require("./config.json");
2const axios = require("axios");
3const redis = require("redis");
4const _ = require("lodash");
5const db = require("./db");
6
7module.exports = (endpoint, parameters) => {
8 db.addRequest("tpg");
9 const params = _.values(
10 _.mapValues(parameters, (value, key) => "&" + key + "=" + value)
11 ).join("");
12 const URL =
13 config.tpg.url + endpoint + ".json?key=" + config.tpg.key + params;
14 return axios.get(URL).catch(error => {
15 console.log(URL);
16 console.log("Error: can't get data from TPG : " + error);
17 });
18};