简体   繁体   English

如何将数据发布到 React Native 应用程序?

[英]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 (全双工)客户端和服务器之间的持久通信通道
  • 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.您可能想阅读有关此主题的内容。

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.

相关问题 如何在获取请求中传递 POST 参数? - 反应本机 - How can I pass POST parameters in fetch request? - React Native 如何在本机反应中发出 POST 请求 - How can I make a POST request in react native 如何确定我的 React Native 应用程序中的 inte.net 速度? - how can I determine internet speed in my react native app? 如何在本机反应中返回应用程序主体中的变量? - How can i return a variable in the body of the app in react native? 如何在 Iphone 上使用我的 React Native 应用程序? - How I can use my React Native app on Iphone? 如何在我的应用程序周围传递道具以反应原生? - How can I pass props around my app in react native? 如何在本机应用程序中实现暗模式 - How can I implement dark mode in react native app 如何打开其他屏幕进入本机应用程序? - How can I open other screens into the react native app? 在 react-native 中运行之前,如何让应用程序等待从从 firestore 获取数据的模块中获取所有数据? - How can i make app wait to get all data from module that get data from firestore before run in react-native? 使用 React-Hook 表单,如何在 React Native 中将数据发布到我的 MongoDB - Using React-Hook Form, How do I post data to my MongoDB in React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM