(Quality Assurance Course, Issue Tracker) Why doesn't the put request test pass?

Error

You can send a PUT request to /api/issues/{projectname} with an _id and one or more fields to be updated. If successful, it should update the updated_on field and return { result: ‘successfully updated’, ‘_id’: _id }.

Situation

Only the above error occurs, all other FCC tests pass.

Tried

  • Search in FCC forum
    I could not find any hints to solve my problem.

  • Manual Tests
    I tried to manually test the posting process and the update process myself on the preview, and I was able to operate it without any problems.

References

If you look in the network tab when you submit you can see the GET after the PUT is returning an empty array.

Log out console.log(d._id === req.query._id) in your _id filter method inside the GET handler.

1 Like

Appreciate your advice!

I did a console output inside the filter and understood that

the type of d._id is ObjectId,

which does not match the type of req.query._id, which is String.

I was able to resolve this by converting it to a string type using
d._id.toString()!