"Use the .env File" Challenge

Tell us what’s happening:
Describe your issue in detail here.

Not sure why my app isn’t giving me credit. I’ve properly used the Secrets (Environment variables) to the appropriate key and value for the challenge.

var express = require('express');
var app = express();
const mySecret = process.env['MESSAGE_STYLE']


console.log(typeof app);

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

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

const myObject = () => ({message: "Hello json"});
app.get("/json", (req, res) => {
  if (process.env.MESSAGE_STYLE === "uppercase") {
    res.json(myObject().message.toUpperCase());
  }
  else res.json(myObject().message);
})























 module.exports = app;

Your project link(s)

solution: https://replit.com/@saunderscox/boilerplate-express-4

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36

Challenge: Use the .env File

Link to the challenge:

I figured it out. I was responding with the string instead of the object.

1 Like

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