Basic Node and Express - Use the .env File

Tell us what’s happening:
I am working locally with VS code

I don’t know why it is not passing the test if this works correctly in the brows, here is the code and the image of the result

let express = require("express");
let app = express();

app.use("/public", express.static(__dirname + "/public"));

app.get("/", (req, res) => {
  res.sendFile(__dirname + "/views/index.html");

app.get('/json', (req, res) => {
  let message = "Hello json"
  if (process.env.MESSAGE_STYLE === "uppercase") {
    return res.json({"message": message.toUpperCase()})
  return res.status(200).json({"message": message})

module. Exports = app;

Here is the content of the .env file


And the imagen for the result

Challenge: Basic Node and Express - Use the .env File

Link to the challenge:

What’s this part for?

The url I am sending for the test is:

And the .env file just contain this


For this and all of the other challenges in the backend section, you just need to submit the base url. In your case, the base url is http://localhost:3000

The tests will make requests to routes as needed.

1 Like

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