Desarrollo Back End y Proyectos APIs - Rastreador de ejercicios

Tell us what’s happening:

La respuesta devuelta desde POST /api/users/:_id/exercises será el objeto de usuario con los campos de ejercicio añadidos. actualmente si le estoy pasando el objeto usuario con los campos que agrego pero insiste en no pasar el test alguien me puede ayudar con esto ?

###Your project link(s)


githubLink: GitHub - Kristopher22/FreeBootcamp

Your browser information:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Desarrollo Back End y Proyectos APIs - Rastreador de ejercicios

Use the res.json method and not send with JSON.stringify

Your exercises respond object has the log array, that isn’t the requirement. The response should look something like this:

  "username": "fcc_test_17145891934",
  "_id": "9j11luges",
  "description": "test",
  "duration": 60,
  "date": "Mon Jan 01 1990"

The mutations you are performing inside the exercises route handler which you then rely on inside the log handler is part of the problem. As you do not need the log array inside the exercises route handler, you really should refactor the code.

I can make it pass by cherry-picking the correct properties out of the newExercise object and merging it with the user and then sending that new object, and keeping the unrelated log array code inside the handler. But I wouldn’t suggest doing that, it is just confusing having code inside the exercises route handler that is affecting data through mutations and then used inside a different handler. The code should be refactored.

What you really should be doing is using a database and an ORM/ODM (e.g. MongoDB/Mongoose).

Sorry for the long-winded explanation, but I can’t really condense it down more.

You are using body-parser but it isn’t in your dependencies.