Although, I’m getting an error
“Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client” which is preventing me from passing them in the FCC part. The error in the console seems to happen once the functional tests start running.
I’ve done a little research on it, and I semi-understand the error but I just have no idea why it’s happening.
My code is here (in the master branch): GitHub - str8lucK1989/MetricImpConverter
(excuse the messiness and commented out code everywhere, was working through bugs lol)
That error occurs when you’ve already sent a response with res.json(), and you still have code afterwards that also tries to send something, like here, when both are invalid:
Awesome. Thanks. That 100% fixed the error and I’ll be sure to keep that in mind for the future. I’m still running into the error of not passing the last 2 challenges despite all my tests passing and having no errors. Upon submitting in the FCC, I’m getting two “undefined” in my console. Did you notice anything else I may have done? Sorry to be a bother and I truly appreciate the help.
I’m not familiar with that project, so I can’t be of much help, sorry.
The undefined comes from these lines in fcctesting.js, it’s initialising a variable error without assigning it to anything, and then logs it. Not sure how that makes sense. The if statement returns false because apparently process.env.NODE_ENV is falsy, and so it goes to res.json({status: unavailable}):