I want to pass data from .ejs
to my node API. For edit
a record I'm passing id of the data.
For that I'm usign click
event like this.
<input type="button" class="btn btn-primary" value="Edit" onclick="edit(<%= data[i].id %>)">
And I create a function in <script>
tag.
function edit(id){
alert(id);
window.location.replace('/bill/edit?id='+id);
}
And my API is this.
router.get('/edit/:id', function (req, res, next) {
console.log("Id is : " , req.query.id);
}
As per I used to before it's right I have search also on it. And it all shows this way but I don't understand that why it's not work for me.
When I run API in postman
I got 404 Error.
<h1>Not Found</h1>
<h2>404</h2>
<pre>Error: Not Found
at E:\myapp\app.js:30:13