Skip to content

Commit e85f227

Browse files
Merge branch 'TraLeeee-patch-1'
2 parents a89b34c + 73cf9c7 commit e85f227

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

content/techniques/mvc.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ async function bootstrap() {
182182
bootstrap();
183183
```
184184

185-
The Fastify API is slightly different but the end result of those methods calls remains the same. One difference to notice with Fastify is that the template name passed into the `@Render()` decorator must include a file extension.
185+
The Fastify API has a few differences, but the end result of these method calls is the same. One notable difference is that when using Fastify, the template name you pass into the `@Render()` decorator must include the file extension.
186+
187+
Here’s how you can set it up:
186188

187189
```typescript
188190
@@filename(app.controller)
@@ -198,6 +200,18 @@ export class AppController {
198200
}
199201
```
200202

203+
Alternatively, you can use the `@Res()` decorator to directly inject the response and specify the view you want to render, as shown below:
204+
205+
```typescript
206+
import { Res } from '@nestjs/common';
207+
import { FastifyReply } from 'fastify';
208+
209+
@Get()
210+
root(@Res() res: FastifyReply) {
211+
return res.view('index.hbs', { title: 'Hello world!' });
212+
}
213+
```
214+
201215
While the application is running, open your browser and navigate to `http://localhost:3000`. You should see the `Hello world!` message.
202216

203217
#### Example

0 commit comments

Comments
 (0)