0

I'm using Node.js and trying to use a local function of a document that needs to use a JSON I send it in res.render. Is there a way to do it? Example of the way I was trying to use it:

<%local_variable = localFunction(sent_JSON)%>

Edit: sorry if this is a simple question, I'm a newbie when it comes to web development.

1 Answers1

0

You can do:

res.render('yourpage', {
    sent_JSON: yourJson,
});
Derick
  • 113
  • 1
  • 8
  • It was sent, however I can't call local functions or variables in the document when i use the <%%> tag to use the sent JSON. I even printed it in the console when the page was loaded, showing that it's been sent correctly. – Gabriel Navarro Dec 15 '20 at 23:54
  • I think this [link](https://stackoverflow.com/a/30539675/13441500) might answer your question. – Derick Dec 16 '20 at 00:01
  • I've been trying that for the last hour, and it didn't work. – Gabriel Navarro Dec 16 '20 at 01:02