Hi All, all tests are passing up until the PUT section - the PUT updating works when I test it but something in the automated test is throwing errors about not being able to set headers after they are sent to the client.
I’ve thrown in a few console logs to see if I can work out what it’s doing but the errors are being thrown on all of the res.json()s in post and in put.
I’ve read every line of the error codes and can’t make head or tail sense of them … e.g. here:
node:5176) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:518:11)
at ServerResponse.header (/home/runner/boilerplate-project-issuetracker/node_modules/express/lib/response.js:771:10)
at ServerResponse.send (/home/runner/boilerplate-project-issuetracker/node_modules/express/lib/response.js:170:12)
at ServerResponse.json (/home/runner/boilerplate-project-issuetracker/node_modules/express/lib/response.js:267:15)
at /home/runner/boilerplate-project-issuetracker/routes/api.js:159:20
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Line 159 is one of the res.jsons
Been fiddling for a few hours with different logic steps but nothing seems to make
a) that test pass
or
b) the header errors go away
So I assume they are related!
Any help is hugely appreciated.
Edit: the failing test is:
When the PUT request sent to /api/issues/{projectname} does not include update fields, the return value is { error: 'no update field(s) sent', '_id': _id }. On any other error, the return value is { error: 'could not update', '_id': _id }.
Your project link(s)
solution: https://boilerplate-project-issuetracker.anilsiv.repl.co
https://repl.it/@anilsiv/boilerplate-project-issuetracker#routes/api.js
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36
.
Challenge: Issue Tracker
Link to the challenge: