Process.env on replit output seems ok but freecode does not accept answer

I get the following error message:

// running tests
The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE (Test timed out)
// tests completed

Here is my code in the file myApp.js:

var express = require('express');
var app = express();
//console.log("Hello World");
/*
app.get('/', function(req, res){
  res.send('Hello Express')
})
*/

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

app.get('/', function(req, res) {
  res.sendFile(__dirname + "/views/index.html");
});
app.get('/json', function(req, res) {
  if(process.env.MESSAGE_STYLE === "uppercase"){
    res.json({"message" : "HELLO JSON"})
  } else {
    res.json({"message" :"Hello json"})
  }
});
module.exports = app;
const mySecret = process.env['MESSAGE_STYLE'] //This line was inserted by replit; not me. I just added a secret to the replit.

Here is my package.json file from the replit:

{
	"name": "fcc-learn-node-with-express",
	"version": "0.1.0",
	"dependencies": {
		"express": "^4.14.0",
		"body-parser": "^1.15.2",
		"cookie-parser": "^1.4.3",
		"fcc-express-bground": "https://github.com/freeCodeCamp/fcc-express-bground-pkg.git"
	},
	"main": "server.js",
	"scripts": {
		"start": "node server.js"
	}
}

The output that I get in the chrome browser is:

// 20211218182334
// https://boilerplate-express.innovations.repl.co/json

{
  "message": "HELLO JSON"
}

Why does not the freecodecamp accept my solution?

Your project link(s)

solution: https://replit.com/@innovations/boilerplate-express

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36

Challenge: Use the .env File

Link to the challenge:

I did not make any changes and just continued asking freecode to run the tests again by hitting the submit button again a few times and suddenly it accepted the same solution and all the tests got passed!

What does it mean?
Was there any bus in the tests that the freecode was running in the background?
Anyhow proceeding to the next lesson now!

It just says that the tested timed out, so maybe the FCC request isn’t getting an answer from the replit server (may be down, or busy, etc), and so the request for /json times out.

After a few trials it should go through.

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