Basic Node and Express - Use the .env File

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

require('dotenv').config();
  
app.get('/json',(req,res)=>{
  
 if (process.env.MESSAGE_STYLE === "uppercase") {
  res.json(  "Hello World".toUpperCase());
  
 } else {
 res.json(  "Hello World");
  
}
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36

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

Link to the challenge:

I’ve edited your post to make your code more legible. When you want to post code on the forum, please ensure that it’s enclosed between two sets of triple backticks. You can do this using the Preformatted Text Tool (</> or CTRL+E) and pasting your code where indicated.

Also, it’s much more helpful to us if you can explain in your own words exactly what you are having difficulty with, so that we can help you more easily!

You are not passing this step because you are not returning the correct json object.

The instructions:

The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"} , depending on the MESSAGE_STYLE value.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.