Wednesday, 17 May 2017

How to send data from server-side (Express.js) to client-side (React.js)?

With Express.js, I'am sending a html file containing a React component within.

app.get('/index', function(req, res) {

      res.sendFile(path.join(__dirname + '/src/index.html'));
  });

For the purposes, let's assume I want to send a unique variable with my html file to every user connecting to localhost:80/index.

How can I send the vatiable from the server-side and how can I retrieve it from the client side ?



via Mit

No comments:

Post a Comment