My Repl is working but solutionlink doesn't approve

Tell us what’s happening:

So I’m working on the Basic Node and Express section and I finished what they asked to write in my repl. file. I made the /Json link responsive with the variable I created in a .env file. (MESSAGE_STYLE=uppercase). I checked and it works when I change it. But when I put in my link for the exercise to be checked, codecamp says it’s not right… It’s very frustrating as I’m struggling with this one for hours and now that I got it, it doesn’t approve it. Please let me know if I’m missing something or that code camp just glitches.

here’s my Repl link:

Thank you,

Your code so far

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

app.get("/json", (req, res) => { if(process.env.MESSAGE_STYLE==="uppercase"){res.json({"message": "HELLO JSON"});
else{res.json({"message": "hello json"});}


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

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

When asking for help it’s better if you link to the editor code and not the full page URL. Just so people can get to the code.

  1. Where did you put the .env file?

Your /json route is returning:

  "message": "hello json"

It should be returning the uppercase response:

  "message": "HELLO JSON"

  1. The lower case response should be “Hello json” not “hello json” (capital “H”)
1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

THANKYOU SO MUCH!! for some reason, I just didn’t see that. Also thanks for the tip on explaining my code better.

1 Like

Good job on passing the test. Glad to have helped.

Happy coding!

1 Like