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: