Http Request To Stackexchange Api Returns Unreadable Json
I'm trying to fetch some json data from the stackexchange api. Receiving the OAuth code and access token works fine. But when calling the actual datafetching endpoints, the respons
Solution 1:
Found the answer myself here: node.js - easy http requests with gzip/deflate compression
Added the following:
var reqData = {
url: "https://api.stackexchange.com/2.2/me/comments?order=desc&sort=creation&site=stackoverflow&access_token="+myToken+"&key="+key,
method:"get",
headers: {'Accept-Encoding': 'gzip'}
}
var gunzip = zlib.createGunzip();
var json = "";
gunzip.on('data', function(data){
json += data.toString();
});
gunzip.on('end', function(){
console.log(JSON.parse(json));
});
request(reqData)
.pipe(gunzip)
Post a Comment for "Http Request To Stackexchange Api Returns Unreadable Json"