James Urian
James Urian

Reputation: 127

How to get reference from an html element in nodejs?

I just started with nodejs and since I can't reference the app.js to the html file since I'm actually starting that js file with the nodejs. Is there a way to achieve this?

Upvotes: 0

Views: 1110

Answers (2)

user11105643
user11105643

Reputation:

Check this tutorial

It's a detailed and great explanation for what you need.

Upvotes: 1

Eneas Marín
Eneas Marín

Reputation: 164

It doesn't work like that. I think you are trying to use the app.js file of a node app as if it was a simple script reference in the html with the tags.

NodeJS runs in the server and the HTML file runs in the client. The server script you are running can provide data to the client, client-server must be "connected" with an API.

If you are using vue or react for the Front-End, check Axios as a library for fetching data via API.

Upvotes: 3

Related Questions