RapidApi 没有看到密钥 header 有什么问题?

What's the problem with RapidApi not seeing the key header?

所以我的 Angular Node.js 应用程序中有这个方法:

async translateWord(word: string) {
const key = '*I put it here*';

const translation = await axios({
  "method": "POST",
  "url": "https://google-translate1.p.rapidapi.com/language/translate/v2",
  "headers": {
    "content-type": "application/octet-stream",
    "x-rapidapi-host": "google-translate1.p.rapidapi.com",
    "x-rapidapi-key": key,
    "useQueryString":true
  },
  "data": {
    "source": "en",
    "q": word,
    "target": "ru"
  }
});

console.log(translation.data);
}

调用方法的结果是

POST https://google-translate1.p.rapidapi.com/language/translate/v2 502 (Bad Gateway)

当我 right-click 在 Chrome 开发工具 window 中请求失败并在新选项卡中打开它时,我收到以下消息:

{"message":"Missing RapidAPI application key. Go to https://docs.rapidapi.com/docs/keys to learn how to get your API application key."}

奇怪的是我的 headers 中确实有密钥:proof

当我通过 RapidApi 接口执行相同的代码片段时,我也得到了正确的翻译。

RapidAPI 支持通过查询参数传递 API 键。您可以通过在 link 中包含以下语法来执行此操作:

https://example.p.rapidapi.com/?rapidapi-key=***************************

但是,请记住,您的 RapidAPI 密钥会在您的整个帐户中使用。如果 link 可公开访问,请小心暴露您的密钥。