Something wrong with this challenge?

Tell us what’s happening:

I’m working on basic Node and express challenge 6 i.e. create a .env file. I created the file .env and wrote MESSAGE_STYLE=uppercase (this is the only line of code we are required to write). I’ve attached my App.js code below.
Your code so far

var express = require('express');
var app = express();

console.log('Hello World');

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

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

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

 module.exports = app;
        

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.3 Safari/605.1.15.

Challenge: Use the .env File

Link to the challenge:

Hi there,
can you edit your code?

insert  your code here 

Hi,
I’ve removed the comments , is it readable now?

Hello,

I experience the same problem.
My source code:

Welcome, centriukas.

This is not the string you are expected to return:

"Hello Json"

I recommend you go to the previous challenge to see the exact string that is expected.

If you are still stuck, I recommend you open your own topic to discuss.

Hello there,

Would you mind sharing a link to your code?

Your code does look correct, so, if there is nothing wrong with the .env file and variable, there must be something else going on.

Hello,

  • have chaged “Hello Json” to “Hello json”. The problem remains.
  • manual tests are OK with the variable MESSAGE_STYLE in .env file .
  • contents of .env file:
 # Scrubbed by Glitch 2020-12-05T14:35:33+0000
MESSAGE_STYLE=uppercase
# MESSAGE_STYLE=lowercase
  • link to source code is provide in my first message.

I have no more ideas how to pass the test. :frowning_face:

Heya @centriukas!

The tests pass on my end when I submit your project. Please make sure you’re submitting the live URL, not the edit URL. In this case, you’ll want to submit https://real-rustic-pink.glitch.me/.

Hi,
here is the link to my code: https://repl.it/@akshitchaturved/boilerplate-express#myApp.js

Thanks for that. Your code passes for me.

If it still does not for you, would you mind sharing any errors in your browser console, when you click submit (I’ve completed this challenge)?

Safari:

Chrome:

It looks like you are submitting the edit link - you’ll want to submit the link to the live app view. :slight_smile:

By live app view , do you mean the link , we get after clicking the +share button?

Hello,

@Sky020: thank you for help.

I passed the test too. The code should satisfy ALL these 3 conditions:

  • process.env.MESSAGE_STYLE === ‘uppercase’
  • lowerCase === ‘Hello json’
  • upperCase === ‘HELLO JSON’

I did not expect so strict rules.

Hello @akshit0201

These links should work for you:

  1. API, JSON {message: “HELLO JSON”} (https://some-url/json)
  2. API for FCC, JSON {passed: true} (https://some-url/_api/use-env-vars)

These links work for me and it means you should pass the test/verification.

1 Like

Thanks for the suggestions @centriukas. These tests do pass for me, yet I’m unable to clear the challenge.

What URL are you submitting to the /learn page?

Do you use this URL to pass the verification?

https://boilerplate-express.akshitchaturved.repl.co

Thanks a lot @centriukas !! . This link worked for me. How did you get it?

@akshit0201: Happy to hear that it helped. The link is from yours “repl.it” which you shared in your message:

1 Like