Created
April 26, 2017 09:22
-
-
Save beepony/8310d3163f8cfc39cf4be37591112e73 to your computer and use it in GitHub Desktop.
nodejs GET request with custom headers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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