Davide Michelotti
Davide Michelotti

Reputation: 215

Express send data async to React

forgive me if the question has already been asked but I don't even know what to look for, I'll explain how it works.

I have a web application which I will call app1 made in react which generates a string and sends it to an express server which saves it in an array with other generated strings, then app1 goes into a waiting state.

Another web application that I will call app2 has a text box in which I insert strings and send them to the express server.

Now I have a problem, if the string entered in app2 is the same as one contained in the express array, espress server must send to app1 that generated the string "your string has been confirmed".

How can I do this asynchronous sending?

I wish it was the server that told app1 "your string has been confirmed" and not that app1 should continue to ask if its string has been confirmed

Upvotes: 0

Views: 167

Answers (1)

Troy Daniels
Troy Daniels

Reputation: 39

It sounds like a websocket would help solve your issue.

app1 would create a websocket to your server, and then the server could send updates to app1 if and when the string is confirmed.

Take a look at this https://github.com/joewalnes/reconnecting-websocket - Ive used this before, and I like it.

Hope this helps :)

Upvotes: 1

Related Questions