Tell us what’s happening:
why am I getting error?
Failed:The response of the endpoint
/json
should change according to the environment variableMESSAGE_STYLE
Challenge Information:
Basic Node and Express - Use the .env File
my code in myApp.js is as follows:
let express = require('express');
let app = express();
console.log("Hello World")
//Serve an Html file
app.get("/", function(req, res) {
res.sendFile(__dirname + "/views/index.html");
})
//serve static assests
abspath = __dirname +"/public"
app.use("/public", express.static(abspath))
//serve json
app.get("/json", function(req,res){
if(process.env.MESSAGE_STYLE=="uppercase"){
res.json({message: "Hello json".toUpperCase()});
}
else
{ res.json({message: "Hello json"});
})
module.exports = app;
why am I getting error?
Failed:The response of the endpoint
/json
should change according to the environment variableMESSAGE_STYLE
project link
https://freecodecam-boilerplate-xre7fa46ukp.ws-us108.gitpod.io
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36