A
A
Alisa942019-05-03 15:44:05
JavaScript
Alisa94, 2019-05-03 15:44:05

How to pass data from regular js file to pug?

Hi all. I've been working on a simple problem for several hours now (although I've also encountered it to this day and have not succeeded), but there is no result.
So, I get data in a regular js file using axios.get request, this data also contains the id of the elements that I then generate on the html page, as the name of the buttons. I have a working version of generating id elements on an html page in the form of button titles, but this way limits me in many ways and makes development difficult. Parallel to this, I use pug to create html pages. So, I need to take the data received in the js file and transfer it to the pug file for further work on it. I want to say right away that I also have a node.js file, but I don’t really understand this. It seems to me that the problem is that I do not know how I need to write a server file (nide.js) for this, but I'm not sure about that either.
Please help me pass the received data from the js file to pug.
Very grateful.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Oksenchuk, 2019-05-03
@Yevhen89

If I understood correctly, then you want to work with the pag through the script, but you understand that it will compile to html, and the script is attached to the html main file, why do you need a pag, js works with the house tree, with the house tree of the html page, and not pug, you need to go from this, the point is that your scripts work with html, with a proxy file in which it is html. You do not need to tie them with a pag, the browser will only read html, css, js. And you need to transfer some kind of value to the html file, don't complicate your life)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question