question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question]How make it work with Handlebars?

See original GitHub issue

I made the code and it sending me an error `router.get(‘/’, function(req, res) { res.render(‘index’, { user: req.user }, { title: ‘Express’ }); });

router.get(‘/tos’, function(req, res) { res.render(‘tos’, { user: req.user }, { title: ‘Terms of Service’ }); });`

<img src='{{user.photos[2].value}}' alt="Avatar Image" /> <span>{{user.displayName}}</span>

Error `C:\Users\VladG\Desktop\Tutorials\Express Web\CSGOGamble\node_modules\express-handlebars\lib\utils.js:18 callback(reason); ^

TypeError: callback is not a function at Immediate.<anonymous> (C:\Users\VladG\Desktop\Tutorials\Express Web\CSGOGamble\node_modules\express-handlebars\lib\utils.js:18:13) at runCallback (timers.js:672:20) at tryOnImmediate (timers.js:645:5) at processImmediate [as _immediateCallback] (timers.js:617:5)`

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewdacommented, Jun 8, 2017

You’re not using the correct syntax for res.render(). You should specify the template (which you’re doing correctly), then a single object for the properties you wish to pass to that template. You’re instead passing in 2 objects, and the second one is in the place of where an optional callback should go. Do something like this instead:

router.get('/', function(req, res) {
    res.render('index', { title: 'Express', user: req.user });
});

router.get('/tos', function(req, res) {
    res.render('tos', { title: 'Terms of Service', user: req.user });
});
0reactions
vladgalcommented, Jun 9, 2017

I need to make a var named user or its inside passport already?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handlebars Tutorial - YouTube
Get the Code Here : http://goo.gl/h81zZAIn this video we'll learn Handlebars by walking through numerous examples. Handlebars is a superset ...
Read more >
Handlebars.js Tutorial: Learn Everything About ...
Written in JavaScript, Handlebars.js is a compiler that takes any HTML and Handlebars expression and compiles them to a JavaScript function.
Read more >
Handlebars.js if block helper
The easiest thing would be to add a custom if_eq helper: Handlebars.registerHelper('if_eq', function(a, b, opts) { if(a == b) // Or === depending...
Read more >
A Step By Step Guide To Using Handlebars With Your Node js ...
Here's what's going on, Handlebars takes a static template file you give it inside the layouts folder (the “index.handlebars” file), this file contains...
Read more >
A DIY question / handlebar / build
If your handlebars are steel, then consider drilling into them and using one additional bolt to prevent rotation.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found