Basic Node and Express - Use the .env File

Tell us what’s happening:
Cannot pass the test even if I got the correct response… I have already looked for other similar issues and trying different version of the code, still I cannot pass it!

Your project link(s)

solution: boilerplate-express - Node.js Repl - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36

Challenge: Basic Node and Express - Use the .env File

Link to the challenge:

if(MySecret == 'uppercase'){

Put a console.log(MySecret) right before this line and tell us what you get.

I don’t see nothing in the console

Now when I click to start the test this happen:
SyntaxError: Unexpected token M in JSON at position 0
at JSON.parse ()
at /home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:101:35
at IncomingMessage. (/home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:33:7)
at IncomingMessage.emit (node:events:390:28)
at IncomingMessage.Readable.read (node:internal/streams/readable:527:10)
at flow (node:internal/streams/readable:1012:34)
at resume_ (node:internal/streams/readable:993:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
node:_http_outgoing:576
throw new ERR_HTTP_HEADERS_SENT(‘set’);
^

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at new NodeError (node:internal/errors:371:5)
at ServerResponse.setHeader (node:_http_outgoing:576:11)
at ServerResponse.header (/home/runner/boilerplate-express/node_modules/express/lib/response.js:794:10)
at ServerResponse.send (/home/runner/boilerplate-express/node_modules/express/lib/response.js:174:12)
at ServerResponse.json (/home/runner/boilerplate-express/node_modules/express/lib/response.js:278:15)
at /home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:113:15
at IncomingMessage. (/home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:33:7)
at IncomingMessage.emit (node:events:390:28)
at IncomingMessage.Readable.read (node:internal/streams/readable:527:10)
at flow (node:internal/streams/readable:1012:34) {
code: ‘ERR_HTTP_HEADERS_SENT’
}
exit status 1

I do not see where you added console.log(MySecret) above the line I referenced above.

sorry, I’m just experimenting with the code … I m gonna put it back

Also, what is the file dev.env for?

nothing, I noticed after that need to use secret tab for that to work in repl

anyway I see that cannot be used MySecret == “uppercase”
it says “MySecret is not defined”

Yes and there is a reason for that. You have a typo.

All good, test passed! Thanks!

At least It was useful to start using this forum :))