Hi Community Folks,
I have a scenario in which I have to pass some custom data based on user's properties to welcome email template in nodebb. How can I achieve this ?
Feedback appreciated
Thanks
Template hello.tpl:
<html>
<body>
<div>hello {message}</div>
<body>
<html>
The code in the controller is res.render('user/hello.tpl', req.query);
. The response I got back is a json instead of a html page:
{
"message": "world",
"loggedIn": true,
"relative_path": "",
"template": {
"name": "user/hello.tpl",
"user/hello.tpl": true
},
"url": "/hello",
"bodyClass": "page-hello"
}
What have I miss? Please advise, thanks!
The NodeBB middleware automatically sets the response type to JSON for any route beginning with api
Set the begining of the route to anything other than api
and it should work.
Alternatively, I think setting
res.locals.isAPI = false
before you render would also work.
Thanks again @yariplus, it works with res.locals.isAPI = false
.
@Bruce-Lee first, remove the .tpl
from the route.
@PitaJ do you mean to code as
res.render('user/hello', req.query);
instead of
res.render('user/hello.tpl', req.query);