如何将cURL转换为axios请求
问题描述:
我显然在这里忽略了一些东西
I'm obviously overlooking something here:
答
我修复了它,我需要将值放在参数中
I fixed it , I needed to put the values in parameters
import axios from "axios";
async function testApi() {
try {
const b = await axios.post("https://oauth.nzpost.co.nz/as/token.oauth2",
params: {
client_id: "xxxxxxxxxxxxxxxxxxxxxxxxx",
client_secret: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
grant_type: "client_credentials"
});
} catch (error) {
console.log(error);
}
}
testApi();