Use the .env File

@yaser, milion times! hahaha . So what are you planning now?

If you really tried all the solutions here, and not working for you----
I would suggest, stop working on the current file and start again with a new link for this challenge. Before taking this decision, you can take a break for few hours and try to solve this for few more times by following the challenge instructions. Moreover, you can share your code here for a review. :grinning:

Thank you you were right, i needed a break and stop pushing myself it was a tiny mistake. Had I rested I would have saved much energy and effort.

1 Like

This is the only solution that works.

It appears that the .env file must be added with MESSAGE_STYLE=uppercase being the only code written in the file.

Everyone else’s solution previously mentioned in this app should work. It worked for me.

This one perfectly works for me.

I haven’t created this .env file with MESSAGE_STYLE=uppercase variable at first

all solutions do not work. including opening .env file with a variable in it.

Could you check my code on glitch. I can’t find any issue with it but it doesn’t pass the test.
https://glitch.com/edit/#!/tar-calico-curio

.env file contains only MESSAGE_STYLE=uppercase

Edit:

Looks like my code is fine, and I bet yours is also fine. It’s issue on glitch’s side.
I found this: http://forum.freecodecamp.org/t/node-and-express-tests-failing/406988
I’ve just moved my code from glitch to repl.it and finally challenge is done. Shame I wasted so much time today.

It also happened with me i wasted a whole day on this bug but repl.it looks better anyways

how did you tested your code ?

hello everyone, I need help here, I don’t understand why my code is not getting through the test.
code :- https://glitch.com/edit/#!/handsome-mixolydian-wildflower

Try to use repl.it Create/modify files there based on Github repository for Node and Express Challenges

process.env.MESSAGE_STYLE == “uppercase” initialize it;

var express = require(‘express’);
var app = express();
process.env.MESSAGE_STYLE=“uppercase”;

// --> 7) Mount the Logger middleware here
app.use(
express.static(__dirname + “/public”));

// --> 11) Mount the body-parser middleware here
app.get("/json",function(req,res){
if(process.env.MESSAGE_STYLE==“uppercase”)
res.json({“message”: “HELLO JSON”})
else res.json({“message”:“Hello json”})
});
this works.

1 Like

Make sure the url you upload ends in ‘/’ and not ‘/json’

thanks ,i had deleted this .env file earlier

now it should work on your glitch

You are right. The whole of it including “module.exports = app;” worked for me after Avery long struggle. Thank you and best regards.

Spent a lot of time on this as well, for me the solution was literally closing my repl.it project, going back to their home page and opening the repl.it project again from the My Repls page.

Very frustrating when you are trying to learn and turns out your code was correct the entire time.

thank you very much. i think mine just got solved. guys i suggest if your case still persists, you should start a new project, paste the git clone repos from the introduction and finally copy and paste all off these post. (i even recommend you do away with all the comments) #ENDSARS IN NIGERIA. PLEASEEEEE…

Hi I created the env. file and input the code MESSAGE_STYLE=uppercase in the file . can you tell me what im missing or misplacing.