Use the .env File: Basic Node and Express -

please help me , I am stuck in this problem and have not found a solution

var express = require(‘express’);
var app = express();
const process = require(‘process’);

if( process.env.MESSAGE_STYLE==“hello world”){

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

have you created the .env file and added the variable to it?

1 Like

No, i have not , here is the concept of problem:
Store the variable MESSAGE_STYLE=uppercase in the .env file. Then tell the GET /json route handler that you created in the last challenge to transform the response object’s message to uppercase if process.env.MESSAGE_STYLE equals uppercase. The response object should become {“message”: “HELLO JSON”}.

You need to add the file and give the value provided in the challenge text, i.e. MESSAGE_STYLE=uppercase

  1. It is telling you to check

if process.env.MESSAGE_STYLE equals uppercase

  1. It’s asking you to res.json() an object

The response object should become {"message": "HELLO JSON"}

  1. I don’t think it will cause issues but you really shouldn’t have this require statement const process = require('process') in the code.
1 Like

A post was merged into an existing topic: Headers Error in .env Challenge