Hello, there.
I have a problem passing this test.
here’s the question.
Create a .env file in the root of your project directory, and store the variable MESSAGE_STYLE=uppercase in it.
Then, in the /json GET route handler you created in the last challenge access process.env.MESSAGE_STYLE and transform the response object’s message to uppercase if the variable equals uppercase. The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"}, depending on the MESSAGE_STYLE value. Note that you must read the value of process.env.MESSAGE_STYLE inside the route handler, not outside of it, due to the way our tests run.
Your project link(s)
solution: https://replit.com/@mujahidjab/boilerplate-express
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Challenge: Basic Node and Express - Use the .env File
Link to the challenge:
here’s my code.
let express = require(‘express’);
let app = express();
console.log(“Hello World”);
app.get(“/”, (req, res) => {
res.sendFile(__dirname + “/views/index.html”);
});
// Assets at the /public route
app.use(“/public”, express.static(__dirname + “/public”));
app.get(“/json”, (req, res) => {
res.json({
message: “hello json”
});
const mySecret = process.env[‘MESSAGE_STYLE’]
});
module.exports = app;