mayday69
mayday69

Reputation: 48

Express js route with different ids

Im using node js with express lib.There are pages like localhost/page/1,localhost/page/2. They are pretty similar but some information must change depending on page id. Im redirecting to this pages with form submit.

<form method='GET' action='/order_page/" + order.id[i] + "'><input type='submit' value='move'></form>

and in my server js

app.get('order_page/:id', checkUserSession, function(request, response) {
    response.send(req.id);
});

it redirects and gives me error Cannot GET /order_page/6

What's the best solution to this issue?

Upvotes: 0

Views: 367

Answers (2)

Alvaro Lozano
Alvaro Lozano

Reputation: 116

I think you should add a "/" before "order_page/:id"

app.get('/order_page/:id', checkUserSession, function(request, response) {
response.send(req.id);});

Upvotes: 1

Liran Bakalash
Liran Bakalash

Reputation: 48

You are missing / before the order_page :

app.get('/order_page/:id', checkUserSession, function(request, response) {
    response.send(req.id);
});

Upvotes: 1

Related Questions