Use the .env File
Here is my solution:
The key.env file:
# Environment Config
# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values
# reference these in your code with process.env.SECRET
SECRET=
MADE_WITH=
MESSAGE_STYLE=uppercase;
# note: .env is a shell file so there can't be spaces around =
myApp.js:
"use strict";
var express = require('express');
var app = express();
app.use(express.static(__dirname + "/public"));
const upper = process.env.MESSAGE_STYLE === "uppercase";
let message = "Hello json";
if (upper) {
message = message.toUpperCase();
}
app.get("/json", (request, response) => response.json({
message: message
}));
//---------- DO NOT EDIT BELOW THIS LINE --------------------
module.exports = app;
When I run the url/json I get “HELLO JSON”. This is the expected output.
If I change the MESSAGE_STYLE variable I get: “Hello json” as I expected.
But the above code fails on the FCC test… Maybe I don’t understand any serious things?
Thanks for help…
I tried to change the JSON message maybe the JSON format is invalid but this also fails on the test while I get the expected output…
upper
? app.get("/json", (request, response) => response.json({
message: "HELLO JSON"
}))
: app.get("/json", (request, response) => response.json({
message: "Hello json"
}))
;