Tell us what’s happening:
Describe your issue in detail here.
I have this code in Repl.it IDE.
app.use("/public", express.static(__dirname+"/public"));
app.get("/json", (req, res) => {
res.json({
message: "Hello json",
});
});
app.get("/", (request, response) => {
let absolutePath = __dirname + "/views/index.html";
response.sendFile(absolutePath);
})
but the following test fails… and says that
-
- The endpoint
/json
should serve the json object{"message": "Hello json"}
*
- The endpoint
Where am I going wrong?
Your project link(s)
solution: boilerplate-express - Node.js Repl - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36 Edg/104.0.1293.70
Challenge: Basic Node and Express - Serve JSON on a Specific Route
Link to the challenge: