How do I communicate between client.js and server.js?

I’m making a program that will get stats from your profile on a site, then make achievements based off those stats. So far I’m just having it so it’ll send me the stats back. Problem is I don’t know how to have it so you type in a username, it tells that the server.js, then gets the stats, sends it to client.js to display onto your screen. I’ve looked around but everything seems too confusing, where do I start?

@Jacklack3 I recommend you research into Web Sockets and implement them. is a great library to start off on.

@Jacklack3 If I understand your question you are just learning how server/client communicate.

Check these concepts:

  • End Points: an address (url) where the server exposes the information and where the client will read it.
  • The role of the Headers: this is how the information is transferred between points.
  • HTTP methods: POST, GET, etc.

Did I understand your question? Hope this helps.

Maybe you can research about templates engines like ejs

This is helpfull if you want to send info from the server to a html view.

1 Like