Hi there,
I'm trying to fetch a token and session id from the backend when a button is clicked. However, among all the console.log() functions I put in the handleSubmit function, only the first one worked, printing out "ok." I am wondering what caused the program fail to fetch the data from the backend (my backend code does generate a token and session id on localhost:5000/api/sessions). I attached a screenshot of (1) the backend code, (2) the frontend code, (3) proxy.js, and (4) my project folder. I do not include a proxy string or object in package.json. Thanks!
Backend
https://dev-to-uploads.s3.amazonaws.com/i/aeqesx6nal99naoj7gaw.png
Frontend (fetch API)
https://dev-to-uploads.s3.amazonaws.com/i/fgf8as8f0f7qbagu0xjk.png
proxy.js
https://dev-to-uploads.s3.amazonaws.com/i/fxi1h2iowx4bxq7mlaoy.png
src folder
https://dev-to-uploads.s3.amazonaws.com/i/n788uaysq2p8lb77u7tr.png
Top comments (1)
Thanks for the reply! It turns out to be the ECONNRESET error. I thought I had got rid of this error, well it just did not show up on the console. Do you have any ideas regarding how to debug this error? I also added req.on("error", function(e) { console.log("error", err }) in my backend code to see whether the error occurred while the backend trying to receive the request, but the terminal did not print out anything.