[英]Axios request response 401 in React app, but working in Postman?
[英]React/Axios receive response status and JSON like Postman
我的端點將發送如下響應:
res.status(400).json({"note","this email is already taken"});
對於 React,我使用 axios 如下
export const signUpUser = (email, password) => {
const headers = {
"Content-Type": "text/plain",
};
return axios
.post(
https://domain.something + "/signup",
{ email, password },
{ headers ,}
)
.then((res) => {
return res;
})
.catch((err) => {
return err;
});
};
但是我無法通過反應提取 JSON 這是控制台日志顯示的內容:
默認情況下 400 是錯誤請求的代碼,嘗試將代碼更改為 200 或 2xx。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.