OK, so I created a .env file with MESSAGE_STYLE=uppercase. Still, the grader isn’t accepting it.
Your code so far
var express = require('express');
var app = express();
// --> 7) Mount the Logger middleware here
console.log("Hello world");
// --> 11) Mount the body-parser middleware here
app.get("/", (req, res) => {
res.sendFile(__dirname+"/views/index.html");
});
/** 1) Meet the node console. */
app.use(express.static(__dirname + "/public"));
/** 2) A first working Express Server */
app.get("/json", (req, res) => {
const message = process.env.MESSAGE_STYLE === "uppercase"?'HELLO JSON':'Hello Json';
res.json({message});
});
/** 3) Serve an HTML file */
/** 4) Serve static assets */
/** 5) serve JSON on a specific route */
/** 6) Use the .env file to configure the app */
/** 7) Root-level Middleware - A logger */
// place it before all the routes !
/** 8) Chaining middleware. A Time server */
/** 9) Get input from client - Route parameters */
/** 10) Get input from client - Query parameters */
// /name?first=<firstname>&last=<lastname>
/** 11) Get ready for POST Requests - the `body-parser` */
// place it before all the routes !
/** 12) Get data form POST */
// This would be part of the basic setup of an Express app
// but to allow FCC to run tests, the server is already active
/** app.listen(process.env.PORT || 3000 ); */
//---------- DO NOT EDIT BELOW THIS LINE --------------------
module.exports = app;
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15.
I’ve edited my question above. As you suggested I created a .env file and assigned the MESSAGE_STYLE variable a value of uppercase. Even though the code is working and I’m able to see the result as “HELLO JSON” ,the grader isn’t accepting my solution.
Any thoughts?
Right, I do not know why i missed this, but here is the instruction:
The response object should become {"message": "HELLO JSON"}
And here is what you have:
res.json({message});
I am still confused as to why you are on this exercise, when it appears you are missing the code for the previous exercises. As I mentioned before, this should come under step 6.
Yes, I deleted some code pertaining to previous exercises but I don’t think that should make any difference because my JSON object is changing with the MESSAGE_STYLE variable and that’s what we are supposed to do in this exercise.