fastify / point-of-view

Template rendering plugin for Fastify
MIT License
338 stars 86 forks source link

I am getting the following error after installing and configuring the lib: reply.view is not a function #381

Closed pablomarttiins closed 12 months ago

pablomarttiins commented 1 year ago

Prerequisites

Fastify version

4.18.0

Plugin version

8.0.0

Node.js version

18.16.0

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

20.04.6 LTS

Description

After installing the lib and configuring it, I am getting the error: reply.view is not a function

Steps to Reproduce

Instalei a lib com:

npm i @fastify/view

I performed the configuration in app.ts.

The configuration was done as follows:

app.register(fastifyView, { engine: { ejs: ejs }, root: path.join(__dirname, 'views'), layout: "./templates/template", viewExt: "ejs", propertyName: "render", defaultContext: { dev: process.env.NODE_ENV === "dev", }, options: {}, })

Expected Behavior

No response

gurgunday commented 12 months ago

Well, it’s because you set the propertyName property to render

You should do reply.render(), or remove propertyName from options

gurgunday commented 12 months ago

Closing this but feel free to write back if the problem isn’t solved