Home > Software engineering >  How can I POST data to a React Native app?
How can I POST data to a React Native app?

Time:09-09

I know how to POST data from a React Native app to the server with axios, but I don't know how I can POST data from the server to React Native. Is there a way to listen for requests from the server, or a way to handle requests to "routes" in the app (if they even exist)?

CodePudding user response:

Either you are looking for

  • Sockets (full duplex) a persistent communication channel between client and server
  • or there might be a miss understanding on your end on how client server architecture is supposed to work, where a client usually only sends requests (and the server replies with a response)
  • and then there is long polling (half duplex)

You might want to read up on this topics.

CodePudding user response:

What do you mean by "POST data from the server to React Native"? React Native is client, and you can't possibly fire a HTTP request to client. If you want to trigger something in React Native from the server, you can just use some real time bi-directional connection. Like HTTP/2 or socket.io, or just simple as long polling

  • Related