I have a node express app, and I am attempting to pass a variable through when rendering my index.hbs
file, like so:
<!DOCTYPE html>
<html>
<body>
Hello.
<a href="/auth/facebook">Login with Facebook</a>
{{req}} <!-- this works fine(ish) -->
<script>
var request = {{req}}; // This throws an error
console.log(request);
</script>
</body>
</html>
The {{req}}
template variable gets outputted as [object Object]
as expected, but when attempting to pass it through via javascript, I get Unexpected identifier
thrown in console. I tried modifying to use triple curly braces instead of double curly braces but that didn't seem to make a difference.
What is the correct way to set template variables using javascript?