Hi,
I’m stuck at the 4th project, the Exercise Tracker, for the [Back End Development and APIs Projects] certification.
I send this code to review:
The problem is the test for parsing the date using the toDateString
always fails with the following text:
// running tests The
date
property of any object in the
log
array that is returned from
GET /api/users/:id/logs
should be a string.. Use the
dateString
format of the
Date
API. // tests completed
The response my service is sending back are following the structure bellow as you can see in the logs I’m sending into the console.
{
"_id": "614a639352e6fafb9f3b5876",
"username": "fcc_test_16322651077",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Mon Jan 01 1990"
}
]
}
Full log for the /api/users/:_id/logs
endpoint case
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65dd1d5e2fff6065631b' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65dd1d5e2fff6065631b",
"username": "fcc_test_16322656939",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65df1d5e2fff60656324' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65df1d5e2fff60656324",
"username": "fcc_test_16322656951",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65e01d5e2fff6065632d' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e01d5e2fff6065632d",
"username": "fcc_test_16322656964",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65e11d5e2fff60656336' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e11d5e2fff60656336",
"username": "fcc_test_16322656975",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65e21d5e2fff6065633f' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e21d5e2fff6065633f",
"username": "fcc_test_16322656987",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65e31d5e2fff60656348' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e31d5e2fff60656348",
"username": "fcc_test_16322656998",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /
QUERY: {}
PRAMS: { _id: '614a65e41d5e2fff60656351' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e41d5e2fff60656351",
"username": "fcc_test_16322657009",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Tue Sep 21 2021"
}
]
}
>>> GET /?from=1989-12-31&to=1990-01-03
QUERY: { from: '1989-12-31', to: '1990-01-03' }
PRAMS: { _id: '614a65e61d5e2fff6065635a' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e61d5e2fff6065635a",
"username": "fcc_test_16322657021",
"from": "Sun Dec 31 1989",
"to": "Wed Jan 03 1990",
"count": 2,
"log": [
{
"description": "test",
"duration": 60,
"date": "Mon Jan 01 1990"
},
{
"description": "test",
"duration": 60,
"date": "Tue Jan 02 1990"
}
]
}
>>> GET /?limit=1
QUERY: { limit: '1' }
PRAMS: { _id: '614a65e61d5e2fff6065635a' }
BODY: {}
----------------------------
RESLT: {
"_id": "614a65e61d5e2fff6065635a",
"username": "fcc_test_16322657021",
"count": 1,
"log": [
{
"description": "test",
"duration": 60,
"date": "Mon Jan 01 1990"
}
]
}
As you could see the date
property inside to each object of the log
array is of type string
.
Is it possible there is a bug on the test ?
Thank you in advice and let me know if I could provide any further usefull information.
Cheers,
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36
Challenge: Exercise Tracker
Link to the challenge: