console error :
code to reproduce error:
var request = require('request');
var url = 'http://api.stackexchange.com/2.2/https://stackoverflow.com/questions';
request({
headers: {
'Accept': 'application/json; charset=utf-8',
'User-Agent': 'RandomHeader'
},
uri: url,
key: 'cawQTENGI5TpoSgBKy7SXw',
method: 'GET',
gzip: true
},
function(err, res, body) {
console.log("response.statusCode" + res.statusCode);
console.log('server encoded the data as: ' + (res.headers['content-encoding'] || 'identity'))
console.log('the decoded data is: ' + body)
});
export default {
name: 'StackApi',
}
My intention is to get all questions, but the documentation of Stack Overflow is hard to understand for me, is it because I am accessing locally the data? I don't understand the Cross-Origin read blocking.
You're using a wrong url
var url = 'http://api.stackexchange.com/2.2/https://stackoverflow.com/questions';
it should be :
var url 'http://api.stackexchange.com//2.2/questions?order=desc&sort=activity&site=stackoverflow'
just provide the site name in your query