这是我的代码,也许有些不对劲。
var options = {
host: 'a.wunderlist.com',
path: '/api/v1/user',
method: 'GET',
headers: {
'X-Access-Token:': 'mytoken',
'X-Client-ID': 'myid'
}
};
var req = https.request(options, function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
});
req.end();
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
我只获取状态代码503,与curl相同的请求工作正常:(
编辑:我使用了开发者网站的卷曲
curl -H "X-Access-Token: OAUTH-TOKEN" -H "X-Client-ID: CLIENT-ID" https://a.wunderlist.com/api/v1/user