Tell us what’s happening:
The path /json is outputting the desired output but still getting error
{"message":"Hello json"}
Below is the code:
var express = require('express');
var app = express();
// console.log("Hello World")
app.use("/public", express.static(__dirname + "/public"));
getpath=__dirname+"/views/index.html";
app.get("/",function(req,res){
res.sendFile(getpath);
})
app.get("/json", (req, res) => {
res.json({
message: "Hello json"
});
});
Your project link(s)
https://boilerplate-express.jamesmerize.repl.co/json
solution: https://replit.com/@jamesmerize/boilerplate-expressjson
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36
Challenge: Serve JSON on a Specific Route
Link to the challenge: