Tell us what’s happening:
the code appears to work and changing the environment variable adjusted the output at /json to say {“message”:“HELLO JSON”} not {“message”:“hello json”}, but the site wont properly score my work (has had no issues up until now).
Your code so far
var express = require(‘express’);
var app = express();
console.log(“Hello World " + process.env.MESSAGE_STYLE);
if (process.env.MESSAGE_STYLE === “uppercase”) {
var message = {
“message”: “Hello json”.toUpperCase()
}
} else {
var message = {
“message”: “Hello json”
}
}
// res.json(message);
;
app.get(”/testing2", function(req, res) {
res.send(“Hello Express”);
});
app.get("/jonathan", function(req, res) {
res.send(“Hello Jonathan!!@#@#”);
});
app.get("/testing", function(req, res) {
res.send(__dirname );
});
app.get("/", function(req, res) {
res.sendFile(__dirname + “/views/index.html”);
});
app.get("/json", function(req, res) {
res.json(message);
}
)
app.use(express.static(__dirname+"/public"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
.
Challenge: Use the .env File
I created the .env file in Files and added MESSAGE_STYLE=uppercase
changing it to anything else has the desired effect, it just doesn’t score me as having it right for some reason.
Link to the challenge: