Last 8 Problems in Exercise Tracker

Link to project

I’ve been stuck on the last 8 test cases for the last 6 hours now, and I’m not really sure what’s happening? These are all related to “/api/users/:id/logs”

You’re going to have to do some basic debugging by logging to the server console your route inputs and your route responses and then look at the errors in the browser console when you run the tests. Right now you have validation errors on the server from the exercise model and errors on the browser console when your server does not transmit the exercise logs. Lots of these errors are caused by your POST exercise route which assumes it will always be provided a date despite instructions in the spec about default dates.

My advice is to log the inputs and responses on each route and compare them with the spec and make sure you implement the behaviors described by the specs.

I’ve been doing that, but one question I have is why, when I make a POST request, code from the GET request gets executed? I have a commented out console.log() in the GET request that displays a message, but consoles that message when I make a POST request.

Not sure what you are talking about. I forked your replit and if I uncomment out the following line and send a post request to /api/users, I do not see a message written to the console.

console.log(`This will log out even though I'm doing a POST request`)

I do not expect the message as the request is a POST request and not a GET request.

Thank you for your reply!

I am seeing the message, perhaps I am doing something wrong? I simply insert a username in Create a New User box, and when I submit two things happen:

  1. My entire database gets logged out (even though I just want one entry to be posted)
  2. ‘This will log out even though I’m doing a POST request’ is displayed on the console.

I finally figured out what you were talking about. This only happens when you try to use the preview window in replit to test your app out. Do you use it as it seems to have strange behavior. It will post but then refresh the page back to the GET request (which is why you are seeing all the records and the console.log statement). Just open the url shown in the preview in a separate window and you will not have this issue.

Thank you, will this affect the tests?

The testsuite tests against the app as if it was in a separate window, so if you are failing tests, it is because you are not meeting the requirements of the project.