我正在使用Rad Studio (Delphi),我正在尝试通过Rad Studio的Rest组件连接到RapidApi端点。尽管我在Rest组件上使用"x-rapidapi-key“和"x-rapidapi-host”作为参数,但我得到了一个401未经授权的响应。有什么想法吗?谢谢
发布于 2021-08-20 08:06:08
目前还不清楚,但您可能需要将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);
});https://stackoverflow.com/questions/66300477
复制相似问题