Skip to content

Instantly share code, notes, and snippets.

@QueueHammer
Created April 16, 2018 22:47
Show Gist options
  • Select an option

  • Save QueueHammer/2c6cd3a17dd794bf7952e2c5433745bb to your computer and use it in GitHub Desktop.

Select an option

Save QueueHammer/2c6cd3a17dd794bf7952e2c5433745bb to your computer and use it in GitHub Desktop.
Synchronous Example
const fs = require('fs');
const request = require('sync-request');
var cfg = JSON.parse(fs.readFileSync('./config.json', 'utf8'));
var query = Object.keys(cfg.apiData)
.map(key => [key, cfg.apiData[key]].join('='))
.join('&');
var res = request('GET', `${cfg.apiUrl}?${query}`);
console.log(JSON.parse(res.getBody('utf8')));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment