E
E
Emptyform2016-09-29 11:08:32
Node.js
Emptyform, 2016-09-29 11:08:32

How to make a redirect in the handler router.delete(...)?

Hey!
The code:

router.delete('/api/users/:id', function*() {
    yield this.userById.remove();

    this.redirect('/api/users');

    this.body = 'Ok';
});

Here the line this.redirect('/api/users'); results in a 404 error. The logger shows that this command causes the server to try to delete again but without a parameter:
--> DELETE /api/users/57ecc74b201259000f29165d 302 32ms 2b
<-- DELETE /api/users
--> DELETE /api/users 404 5ms -

How can I correctly call a redirect? The point is that after the removal it worksrouter.get('/api/users', ...);

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question