Skip to content

Commit 6fc927d

Browse files
committed
chore: add another example for using the response directly
Some response functions don't actually return the response object, which is why it needs to be returned directly.
1 parent a00d08d commit 6fc927d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,19 @@ import {Controller, Req, Res, Get} from "routing-controllers";
262262
export class UserController {
263263
264264
@Get("/users")
265-
getAll(@Req() request: any, @Res() response: any) {
265+
getAllUsers(@Req() request: any, @Res() response: any) {
266266
return response.send("Hello response!");
267267
}
268268
269+
@Get("/posts")
270+
getAllPosts(@Req() request: any, @Res() response: any) {
271+
// some response functions don't return the response object,
272+
// so you need to return it explicitly
273+
response.redirect("/users");
274+
275+
return response;
276+
}
277+
269278
}
270279
```
271280

0 commit comments

Comments
 (0)