Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 连接react native和node js_Node.js_React Native - Fatal编程技术网

Node.js 连接react native和node js

Node.js 连接react native和node js,node.js,react-native,Node.js,React Native,如何从react native调用在localhost上运行的api。我正在使用expo cli并使用expo app在真实设备上运行应用程序。我尝试获取(“https://localhost:3000)但那不行,请帮忙 网络错误 在createError中的节点\u modules\axios\lib\core\createError.js:16:14处 位于handleError中的节点\u modules\axios\lib\adapters\xhr.js:84:24 在EventTarg

如何从react native调用在localhost上运行的api。我正在使用expo cli并使用expo app在真实设备上运行应用程序。我尝试获取(“https://localhost:3000)但那不行,请帮忙

网络错误 在createError中的节点\u modules\axios\lib\core\createError.js:16:14处 位于handleError中的节点\u modules\axios\lib\adapters\xhr.js:84:24 在EventTarget.prototype.dispatchEvent中的节点\u modules\event target shim\dist\event target shim.js:818:20处 在setReadyState中的节点_modules\react native\Libraries\Network\XMLHttpRequest.js:600:10处 在节点\u modules\react native\Libraries\Network\XMLHttpRequest.js:395:6 in\uu didCompleteResponse 在emit中的节点\u modules\react native\Libraries\vendor\emitter\EventEmitter.js:189:10 在节点\u modules\react native\Libraries\BatchedBridge\MessageQueue.js:416:4的调用函数中 在节点\u modules\react native\Libraries\BatchedBridge\MessageQueue.js:109:6 in\uuuuu-guard$argument\u 0 在\uuuGuard中的节点\u modules\react native\Libraries\BatchedBridge\MessageQueue.js:364:10 在callFunctionReturnFlushedQueue中的节点_modules\react native\Libraries\BatchedBridge\MessageQueue.js:108:4处
在[native code]:callFunctionReturnFlushedQueue中为null

尝试将https更改为http确保您的服务器在端口3000上运行

fetch("http://localhost:3000").then((data)=>{
  console.log(data);
});

尝试了此操作,但在节点\u modules\axios\lib\core\createError.js:16:14处显示此错误网络错误,在节点\u modules\axios\lib\adapters\xhr.js:84:24处显示此错误,在节点\u modules\event target shim\dist\event target shim.js:818:20处显示此错误EventTarget.prototype.dispatchEventohh,您的模拟器与本地开发人员计算机是不同的计算机。您可以使用或