What’s happening:
I have this code for my myApp.js file on Repl.it:
const express = require("express");
const app = express();
const homePath = `${__dirname}/views/index.html`;
const assetsPath = `${__dirname}/public/`;
require("dotenv").config();
app.get("/", (req, res) => res.sendFile(homePath));
app.use("/public", express.static(assetsPath));
console.log("process.env:", process.env);
app.get("/json", (req, res) => {
const message = "Hello json";
const messageUpper = message.toUpperCase();
if (process.env.MESSAGE_STYLE === "uppercase") {
res.json({"message": messageUpper});
} else {
res.json({"message": message});
}
});
And when I go to /json
in my browser I can see the expected JSON object. But the test doesn’t pass. I don’t get why.
Your project link(s)
solution: https://boilerplate-express.dragonosman.repl.co
Browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 Edg/88.0.705.68
.
Challenge: Use the .env File
Link to the challenge:
Any help is appreciated. Thanks in advance.