Tell us what’s happening:
I’m doing the Exercise Tracker project but running into failed tests when I POST to /api/users/:_id/exercises. The directions aren’t clear from my perspective - am I supposed to be returning a User object like the requirements specify, or an Exercise object like (see below, I cant add more than 2 links)?
This is the object I’m currently retuning:
{
username: ‘fcc_test_16357917516’,
description: ‘test’,
duration: 60,
date: ‘Tue Jan 02 1990’,
_id: new ObjectId(“61803388bf2337896856b06e”),
__v: 0
}
I’ve figured it out. A simple mistake was not passing the duration as an integer. The other mistake is listed below.
To anyone having an issue not passing a POST request onto exercises successfully:
I was working locally, and ended up having an issue with getting the correct date. I was being passed a date string, formatting it, and sending it back. The problem became a timezone issue, where my local machine was making a conversion to UTC, after being passed a date that was in GMT. This caused the date to roll back. Moving my work into replit fixed this.
For those that want to work locally: I parsed the given date into a UNIX integer, added 24 hours to it, and converted it back to a UTC date string. This made up for the rollback occurrences.