簡體   English   中英

我有一個 NodeJS 后端我正在開發與 ReactJS 前端一起工作,但我不斷收到 500 錯誤

[英]I have a NodeJS backend I am developing to work alongside a ReactJS frontend but I keep getting a 500 error

我正在使用 Insomnia 測試我的 NodeJS 后端,雖然它在 Insomnia 中沒有問題,但我每次都在前端收到 500 錯誤。 我想知道是否有人知道這可能來自哪里,如果就像我說的那樣在我的端點測試程序上運行得很好。 因為它是一個 500 錯誤,所以它不是很具有描述性。 如果需要,可以共享鏈接

const handleSubmit = e => {
e.preventDefault();
console.log("cred username", creds.username);
axios
  .post("https://exampleapi/api/login")
  .then(res => {
    console.log(res.data);
    localStorage.setItem("token", res.data.access_token);
    props.history.push("/");
  })
  .catch(err => console.log(err.response)); };

所以我發現這是我的帖子請求中的一個錯誤應該被包括在內的是

  const handleSubmit = e => {
e.preventDefault();
console.log("cred username", creds.username);
axios
  .post("https://mystery-doggo.herokuapp.com/api/login", creds)
  .then(res => {
    console.log(res.data);
    localStorage.setItem("token", res.data.payload);
    props.history.push("/");
  })
  .catch(err => console.log(err.response));

};

鏈接后的“creds”並將 res.data.access_token 更改為 res.data.payload

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM