Alex Polkhovsky
Alex Polkhovsky

Reputation: 3360

Nested route in node / express js

I attempting to configure a nested route in Express application like so:

app.put('api/template/:id/page/:pageID', updateTemplatePage);

But when my page makes the call, I get a 404 back. My log shows this:

PUT /api/template/519537192e20b47409c46e72/page/home 404 4ms

home is my page ID in this case, so the call URL looks valid to me. Simpler calls, like GET /api/template/519537192e20b47409c46e72 work just fine. How can I make this work?

Upvotes: 1

Views: 1554

Answers (1)

Alex Polkhovsky
Alex Polkhovsky

Reputation: 3360

I was missing '/' in front of the path. Should be like this:

app.put('/api/template/:id/page/:pageID', updateTemplatePage);

Thank you all for your suggestions.

Upvotes: 1

Related Questions