.env Basic Node and Express - Use the .env File file

This is not exactly as it should be:

res.json({message: "Hello Json"});

Strange, in the previous challenge they accept this model… i’ve tried both and they still fail ):

I cannot see your updated code. Could you share the link again?

There is it!

I am still seeing this:

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

The line in the else is not going pass the tests

why isn’t? this if-else is in the model shared on hint

The solution was in app.get > app.use

app.use('/json', (req, res) => {
	let response = "Hello json";

	if(process.env.MESSAGE_STYLE === 'uppercase') {
		return res.json({message:response.toUpperCase()})
	} else {
  	return res.json({message:response})

Also, answer found here :wink:

Thx for the help :smiley:

I am glad you managed to pass.

What I was trying to get you to notice is:

res.json({"message": "Hello Json"});

Should be:

res.json({"message": "Hello json"});

Small letter j

1 Like