There seems some issue with the exercise

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:

Hello there,

Please note: The tests work by taking the link you provide, and appending the required endpoint to the provided link. So, if you input this link:

https://boilerplate-express.jamesmerize.repl.co/json

The tests will test this link:

https://boilerplate-express.jamesmerize.repl.co/json/json

Hope this clarifies

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.