Tell us what’s happening:
Based on what I learn I think I have put up the right code, however whenever I try to access the locallink/json it only shows “Not found” instead of the object I created
###Your project link(s)
solution: http://localhost:3000
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0
Challenge Information:
Basic Node and Express - Serve JSON on a Specific Route
This is my code below
let express = require('express');
let app = express();
console.log("Hello World");
/*app.get("/", function(req,res){
res.send("Hello Express");
})*/
app.get("/", function(req,res){
const absolutePath = __dirname + '/views/index.html';
res.sendFile(absolutePath);
});
app.use("/public",express.static( __dirname + "/public"));
app.get("json", function(req,res){
res.json(
{"message": "Hello json"});
});
module.exports = app;