Open ilterugur opened 2 years ago
package.json:
"express-handlebars": "^6.0.6", "nestia-helper": "^3.0.9",
main.ts:
import { engine as handlebarsEngine } from 'express-handlebars'; ..... ..... const viewEngineTemplatesRoot = join(rootDirName, 'views'); app.engine( 'handlebars', handlebarsEngine({ defaultLayout: false, }), ); app.setViewEngine('handlebars'); app.setBaseViewsDir(viewEngineTemplatesRoot);
app.controller.ts:
import { Controller, Render } from '@nestjs/common'; import { TypedRoute } from 'nestia-helper'; import { AppService } from './app.service'; @Controller() export class AppController { constructor(private readonly appService: AppService) {} @TypedRoute.Get() @Render('index.handlebars') root() { const message = this.appService.getHello(); return { message }; } }
Error: TypeError: Cannot create property '_locals' on string '{"message":"Hello World!"}'
TypeError: Cannot create property '_locals' on string '{"message":"Hello World!"}'
package.json:
main.ts:
app.controller.ts:
Error:
TypeError: Cannot create property '_locals' on string '{"message":"Hello World!"}'