Use the .env File

Hey,

What am I getting wrong here? I seem to get the right output when I run localhost:3000/json: ( {“message”:“HELLO WORLD”} )

Thanks

require('dotenv').config();
let express = require('express'); 
let app = express();


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

Hi there - I’ve edited your post to include a link to the challenge in question. It’s helpful if you can include this link, to give context to your post.

The challenge instructions:

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

The object which your code is returning does not match this.

1 Like

Oops, it’s ‘Hello json’. Thanks for pointing that out!