我正在使用“请求”尝试这个示例
const request = require('request');
request(
{
url: 'https://api.imgur.com/3/gallery/hot/top/day/0',
headers: {
Authorization: { 'Client-ID': '04e2c49522b2562' },
},
},
(e, r, body) => {
console.log(body);
},
);
收到此错误:
"data":{"error":"Malformed auth header","request":"\/3\/gallery\/hot\/top\/day\/0","method":"GET"},"success":false,"status":403}
答案 0 :(得分:1)
不要将Authorization标头设置为对象,而是尝试将其设置为字符串:
Authorization: 'Client-ID 04e2c49522b2562',
有关更多详细信息,请参见Custom HTTP Headers。