[英]How can I POST data to a React Native app?
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.我知道如何使用 axios 将数据从React Native 应用程序发布到服务器,但我不知道如何将数据从服务器发布到 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)?
有没有一种方法可以监听来自服务器的请求,或者有一种方法可以处理应用程序中对“路由”的请求(如果它们甚至存在的话)?
Either you are looking for要么你正在寻找
Sockets
(full duplex) a persistent communication channel between client and server Sockets
(全双工)客户端和服务器之间的持久通信通道 You might want to read up on this topics.您可能想阅读有关此主题的内容。
What do you mean by "POST data from the server to React Native"? “将数据从服务器发布到 React Native”是什么意思? React Native is client, and you can't possibly fire a HTTP request to client.
React Native 是客户端,你不可能向客户端发出 HTTP 请求。 If you want to trigger something in React Native from the server, you can just use some real time bi-directional connection.
如果您想从服务器触发 React Native 中的某些内容,您可以使用一些实时双向连接。 Like HTTP/2 or socket.io, or just simple as long polling
像 HTTP/2 或 socket.io,或者像长轮询一样简单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.