My code seems to work, but the test doesn't pass

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.

Hey @DragonOsman,

Unfortunately this is a known problem and is currently being fixed on. Here is the github issue:

Hopefully this would be fixed ASAP, but for the current time, you can skip this challenge and go on to the next one. Thank you for the understanding…

Thanks for the info.

Yeah, hopefully it’ll be fixed soon. For now I’ve taken your advice and skipped this challenge.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.