Tell us what’s happening:
Even though the json route is working with ifElse, I don’t know why I can’t be approved in this lesson.
Can someone help me?
myApp.js
var express = require('express');
var app = express();
console.log("Hello World");
absolutePath = __dirname + '/views/index.html';
absolutePath1 = __dirname + '/public';
app.get('/', (req, res) => {
// res.send("Hello Express");
res.sendFile(absolutePath);
app.use('/public', express.static(absolutePath1));
});
const mySecret = process.env['MESSAGE_STYLE'];
let response = "Hello json";
app.get('/json', (req, res) => {
// res.json({"message": "Hello json"});
if (mySecret === "uppercase") {
res.json({"message": response.toUpperCase()});
// res.json(mySecret);
} else {
res.json({"message": response});
}
});
Your project link(s)
solution: https://replit.com/@diegodmitry/boilerplate-expressjson
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:98.0) Gecko/20100101 Firefox/98.0
Challenge: Use the .env File
Link to the challenge: