node.js - Passing data from one page to another using Node, Express & EJS -


i've got following routes set up:

router.get('/', function(req, res) {     res.render('index', {}); });  router.post('/application', function(req, res) {   res.render('application', {twitchlink : req.query.twitchlink}); }); 

i've got 2 views set properly.

this i've got in 'index' view:

<form class="form-horizontal" action="/application", method="post", role="form">     <input type="url" name="twitchlink" required>     <button class="btn btn-success">submit</button> </form> 

submitting form take me application view.

<script>var twitchlink = <%- json.stringify(twitchlink) %></script> <script>console.log(twitchlink)</script> 

this should log out link submitted, right? however, these 2 lines:

uncaught syntaxerror: unexpected end of input uncaught referenceerror: twitchlink not defined 

i think need put quotes around <%- json.stringify(twitchlink) %>, this:

var twitchlink = '<%- json.stringify(twitchlink) %>' 

in example, come out as:

var twitchlink = foo.bar.com 

what want is:

var twitchlink = 'foo.bar.com' 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -