I'm facing a challenge in passing the test for a freeCodeCamp project that involves adding from, to, and limit parameters to a GET /api/users/:_id/logs request to fetch part of a user's log. From and to represent dates in yyyy-mm-dd format, while limit is an integer indicating how many logs to return.
Below is an example of the expected response:
{
username: "fcc_test",
count: 1,
_id: "5fb5853f734231456ccb3b05",
log: [{
description: "test",
duration: 60,
date: "Mon Jan 01 1990",
}]
}
I am currently returning the same response as shown in the example.
Here's my database query function:
export const fetchExerciseLogs = async (
userId: string,
from?: string,
to?: string,
limit?: string
): Promise<FetchExerciseLogsResult | undefined> => {
// Code logic here...
};
If you prefer, you can access the full code on replit by following this link:
I attempted to return an empty array instead of "no logs found," but it still didn't pass the test. Thank you for your help!
For more details on the project requirements and user stories, visit: https://www.freecodecamp.org/learn/back-end-development-and-apis/back-end-development-and-apis-projects/exercise-tracker