简体   繁体   中英

Transfer data from Node backend to React frontend

What I want to achieve is having a react application receive data posted to a Node-js server. Currently, the Node server receives a POST from an external source with a list of items. When the Node server receives the data, I want to send the data to the react application. This data will be used in the react application to display the listed items. How would I proceed to make this possible? Any advice is appreciated!

Thank you!

You can do this using Web Sockets . It would look something like this

  1. Your app connects to your API and maintains a socket
  2. The external source will POST to your API
  3. API handles the POST request
  4. Then the API passes some data on to the React app over the web socket
  5. Your app consumes said data
  6. Profit?

Socket.IO is a popular JavaScript library for web sockets with fallbacks and stuff.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM