Reputation: 5167
I am integrating api
with Node.js
and I have to set src
attribute of script as server variable.
Here is real code.(what i want to execute)
Server side
res.render('sample', {usertoken:'somerandomstring'});
Client side
script(src='https://apibaseurl/'+#{usertoken}+'/en.min.js')
The result I want is
script(src='https://apibaseurl/somerandomstring/en.min.js')
How to do it and what am i wrong?
Upvotes: 0
Views: 362
Reputation: 408
Define it first:
(Client side)
script.
var usertoken ="#{usertoken}";
var script = document.createElement('script');
script.src = "https://apibaseurl/" + usertoken + "/en.min.js";
document.body.appendChild(script);
Upvotes: 1