Basic Node and Express - Use the .env File

Tell us what’s happening:
My code is here:

let express = require(‘express’);
let app = express();

app.get(“/”, (req, res) => {
res.sendFile(__dirname + ‘/views/index.html’)
});

app.use(‘/public’, express.static(__dirname + ‘/public’));

app.get(“/json”, (req, res) => {
if (process.env[‘MESSAGE_STYLE’] == “uppercase”) {
res.json({“meesage”: “HELLO JSON”})
} else {
res.json({“meesage”: “Hello json”});
}
});

It won’t pass the test and I cant’ figure out why.
Does anyone know how to solve this problem?

Your project link(s)

solution: boilerplate-express - 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/114.0.0.0 Safari/537.36

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

Link to the challenge:

The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"}

Your code

    res.json({"meesage": "HELLO JSON"})
  } else {
    res.json({"meesage": "Hello json"});

The property you are asked to use is message

Lol, that was a stupid mistake by me. Thanks a lot!

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