Tell us what’s happening:
Hello guys, I need a bit of help here. It’s getting a little frustrating that what ever i do, i cannot pass the following requirements to this challenge, yet the code seems to be working properly. I’d appreciate any help you can give me.
You can POST to /api/users/:_id/exercises with form data description , duration , and optionally date . If no date is supplied, the current date will be used. The response returned will be the user object with the exercise fields added.
You can make a GET request to /api/users/:_id/logs to retrieve a full exercise log of any user. The returned response will be the user object with a log array of all the exercises added. Each log item has the description , duration , and date properties.
Dear twotani,
Thank you for your interest in my topic. userId in exercise is actually the “_id” from PersonSchema; meaning every exercise in the schema has its own unique “_id” (not that it make any difference). But I am apt for having users and their properties separate from each other.
However, that is not the issue. The returned object (res.json), is working according to the given example by the FCC; clean or unclean, it works accordingly to said example. I’d appreciate it if you check it out and see the response. And yet I have no idea why it does not pass. You can see the results which fcc is receiving from my server in the console.
I’m not sure at all because when I did that issue tracker I was using other routes. It seems the criteria have changed but I do remember that I could not just enter the userid as a string. You have to use a function that returns the id.
const {ObjectId} = require(‘mongodb’)
and then ObjectId(idstring) ;
I really don’t know if that is going to resolve your issue but can you try this out first?
Dear mientje,
Yes, the criteria have changed but that is not the issue. The code can perfectly read URL queries and successfully finds them in the database. Also, the “JSON response” that it sends is correct according to the tests. You can try it and you’ll see the query and the response in the console and the webpage. After monitoring what FCC sends and the response it gets, I’m still wondering what’s wrong with the code.
Your GET route is failing because you are returning an object containing logs, not log.
Your POST route is failing because you are returning a date of 1990-01-02 and the test is expecting 1990-01-01 (from the source). This looks like a time zone issue to me but running on repl.it, the client (fCC) and server (repl.it) should both be in UTC so that shouldn’t matter. So, do a quick check for anything that might be messing with the timezone in your code or some other issue that would make the fCC server and your code believe they are on different sides of the date line. Otherwise, try manipulating the date in UTC or try to determine the timezone offset and alter the date to be correct.
Dear jeremy.a.gray,
Sincerely, LOVE YOU. Changed logs to log , and it immediately passed all but the You can POST to /api/users/:_id/exercises with form data description, duration, and optionally date. . That typo wasted 3 days !!!
Still got nowhere with post thing though.