Wednesday 26 August 2020

New to using Node and making a POST request and it is coming back blank/ {}

app.post("/api", (request,response) => { console.log(request.body) data = request.body console.log(data) }) This is my post requestfunction submitValues(){ start = document.getElementById("start").value; end = document.getElementById("end").value console.log(start,end) // findShortestPath(graph, start, end) data = {start, end} options = { method: "POST", headers: { "Content-Type":"applcation/json" }, body: JSON.stringify(data) } fetch("/api", options) } This is the function from when pressing a button gets the values then tries the POST request

Submitted August 26, 2020 at 12:28PM by JoshG232

No comments:

Post a Comment