I am trying to pass a value as JSON from my back end to the front end of my application. I am currently running express.js and the connection for all post methods is PERFECT.
Upon a button click in the FRONT-END in my application I want to get back an invoice number from my server.
On the front end my code looks like this with jQuery:
$.get("/invoiceNumber", function(data) {
console.log(data.number);
});
On the back end it looks like this:
app.get("/invoiceNumber", function(req, res) {
res.json({ number: 4 });
});
Currently I am passing 4 just as a test.
The Error I am getting is:
GET http://127.0.0.1:3000/invoiceNumber 404 (Not Found)
If I try to go directly to:
I get:
Cannot GET /invoiceNumber