0
Good afternoon, I am creating a function in an api that will make a request via post, I did using fetch on the page with reactjs and now I have to migrate to the api but when making the request it generates an error saying that fetch is not a function, when migrating pro Xios and generated the following error:
(Ode:3612) Unhandledpromiserejectionwarning: Error: Request failed with status code 400
I know this error is given to the fact that the service is out of air but it was working with the fecth requisitions made on the page.
const dataCard = req.body;
let axiosConfig = {
headers: {
Accept: "application/json",
"Content-Type": "application/json",
MerchantId: "xxxxxxxxxxxxxxxxxxxx",
MerchantKey: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
}
const url = "https://apisandbox.braspag.com.br/v2/sales/"
const data = JSON.stringify(dataCard)
await axios.post(url,data,axiosConfig)
.then((res)=>{
console.log(res)
})
My error was server-side and not client-side, the questions are different.
– Jason Beestart