【发布时间】:2022-02-01 11:03:05
【问题描述】:
大家好,正如标题所说,我找不到解决方案。
这里是 cURL:
curl "https://test.api.amadeus.com/v1/security/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials&client_id={client_id}&client_secret={client_secret}"
这是我从服务器收到 400 错误的代码:
const getToken = async () => {
try {
const res = await axios.post(
"https://test.api.amadeus.com/v1/security/oauth2/token",
null,
{
params: {
client_id: process.env.REACT_APP_AMADEUS_API_KEY,
client_secret: process.env.REACT_APP_AMADEUS_SECRET_API_KEY,
grant_type: "client_credentials",
},
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
console.log(res);
} catch (error) {
console.log(error);
}};
【问题讨论】:
标签: javascript reactjs api axios