我正在使用 Rad Studio (Delphi),我正在尝试通过 Rad Studio 的 Rest 组件连接到 RapidApi 端点。虽然我使用“x-rapidapi-key”和“x-rapidapi-host”作为 Rest 组件的参数,但我得到了 401 未授权响应。有任何想法吗?谢谢
问问题
407 次
1 回答
1
目前尚不清楚,但可能您需要传递x-rapidapi-host
和x-rapidapi-key
作为请求标头,而不是参数。
例如,尝试这样的事情
var axios = require("axios").default;
var options = {
method: 'GET',
url: 'https://example.p.rapidapi.com/',
params: {query: 'something here'},
headers: {
'x-rapidapi-host': 'example.p.rapidapi.com',
'x-rapidapi-key': '12345'
}
};
axios.request(options).then(function (response) {
console.log(response.data);
}).catch(function (error) {
console.error(error);
});
于 2021-08-20T08:06:07.740 回答