Skip to content

Instantly share code, notes, and snippets.

@beepony
Created April 26, 2017 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beepony/8310d3163f8cfc39cf4be37591112e73 to your computer and use it in GitHub Desktop.
Save beepony/8310d3163f8cfc39cf4be37591112e73 to your computer and use it in GitHub Desktop.
nodejs GET request with custom headers
const request = require('request');
const options = {
url: 'https://www.reddit.com/r/funny.json',
method: 'GET',
headers: {
'Accept': 'application/json',
'Accept-Charset': 'utf-8',
'User-Agent': 'my-reddit-client'
}
};
request(options, function(err, res, body) {
let json = JSON.parse(body);
console.log(json);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment