Unable to understand on how to approach the problem, it says
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_STYLEinside the route handler, not outside of it, due to the way our tests run.
It sounds like the challenge is to transform the value, but MESSAGE_STYLE is not a function. how can I use to transform the value?
###Your project link(s)
Create a .env file in the root of your project directory, and store the variable MESSAGE_STYLE=uppercase in it.
Once you’ve done this, you do not need to modify this in any way.
Instead, in your /json route handler, you create a conditional statement which returns a response object, depending on the value of the MESSAGE_STYLE variable.
The conditional statement should return {"message": "HELLO JSON"} if the value of MESSAGE_STYLE is uppercase or {"message": "Hello json"} if not.
let express = require('express');
let app = express();
let process = require('dotenv').config();
app.get("/", function(req,res){
res.sendFile(__dirname + "/views/index.html")
})
app.use("/public", express.static(__dirname + "/public"))
app.get("/json", function(req,res){
if(process.env.MESSAGE_STYLE === 'UPPERCASE'){
res.json({"message": "Hello JSON"});
}else{
res.json({"message": "Hello json"});
}
})
console.log(process.env.MESSAGE_STYLE);
module.exports = app;
the console.log gives me undefined, seems like it can read process but nothing on process called env, so I did console.dir and it gives { parsed: { MESSAGE_STYLE: 'uppercase' } }