Hi There,I am following this very good tutorial : [NODE.js JSON Api][1]But I am really struggling to not understand how to use it.I am trying to figure out how to write into my index.js route file to have the listing of content of the JSON file when visiting /users URL :What is strange to me is the idea to have the ROUTE into the API Code likeapp.get("/users", (req, res) => {fs.readFile(dataPath, "utf8", (err, data) => {if (err) {throw err;}res.send(JSON.parse(data));});});Does anybody with time to help ?thanks in advance
Submitted July 18, 2020 at 09:55PM by WilliamRails
No comments:
Post a Comment