1 year ago

#388968

test-img

RSA

how to update a variable in <script> tag from main?

In index.ejs I have a word cloud that is using wordcloud2.js.

<canvas id="canvas"></canvas>
            <script>
                WordCloud(document.getElementById('canvas'), {
                    list: targetlist}); 
            </script>

In the main script(app.js) which is using express the following code generates targetlist and after that index.ejs will render again. I try to send the targetlist from the main script to front to generate word cloud.

for (const [key, value] of Object.entries(output.list)) {
               targetlist.push([`${key}`, value]);            
            }        
            response.render('index');

in my try I get Uncaught ReferenceError: targetlist is not defined error.

javascript

html

node.js

express

0 Answers

Your Answer

Accepted video resources