简体   繁体   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

I am testing my NodeJS backend using Insomnia and while it does work no problem in Insomnia I am getting a 500 error on the frontend every time.我正在使用 Insomnia 测试我的 NodeJS 后端,虽然它在 Insomnia 中没有问题,但我每次都在前端收到 500 错误。 I was wondering if anyone maybe knew where this could be coming from if like I said it works just fine on my the endpoint testing program.我想知道是否有人知道这可能来自哪里,如果就像我说的那样在我的端点测试程序上运行得很好。 Since it is a 500 error it is not very descriptive.因为它是一个 500 错误,所以它不是很具有描述性。 Links can be shared if needed如果需要,可以共享链接

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)); };

So I figured it out it was an error in my post request would should have been included was所以我发现这是我的帖子请求中的一个错误应该被包括在内的是

  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" after the link and change res.data.access_token to res.data.payload链接后的“creds”并将 res.data.access_token 更改为 res.data.payload

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我在 Express 后端的补丁请求中收到错误代码 500? - Why am I getting an error code 500 on patch request for Express backend? 为什么在抓取JavaScript时出现500错误 - Why am I am getting 500 Error while crawling in javascript 为什么由于Jquery出现500错误? - Why am I getting a 500 error due to Jquery? 为什么我在提交表单时收到 500 错误? - Why am I getting a 500 error on form submit? 我是否滥用了我的 POST 请求? 我一直收到 400/500(错误的请求) - Am I misusing my POST request? I keep getting 400/500 (bad request) 我在 reactjs 中收到 Html Webpack Plugin 的错误 - I am getting an error of Html Webpack Plugin in reactjs 检查 `News` 的渲染方法。 我在 reactjs 中收到此错误 - Check the render method of `News`. i am getting this error in reactjs 如果我有一个 React 前端和一个微服务后端,我可以有两个部署目标(S3 用于前端,EKS 用于后端)吗? - If I have a React frontend and a microservices backend, can I have two deployment targets (S3 for frontend, EKS for backend)? 当我拥有键和值时,为什么会出现错误? - Why am I getting the error when I have the key and value? 为什么我在 NodeJS 中收到这个意外的 HTTP 错误 - Why am I getting this UNEXPECTED HTTP error in NodeJS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM