React本机fetch()导致未知错误错误:错误:没有此类文件或目录,请打开“C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release

wydwbb8l  于 2023-01-27  发布在  React
关注(0)|答案(1)|浏览(132)

I have made a simple REST API, and I have a react native application where I am trying to call the API with fetch. The server is running on the same computer as the react native application, in my fetch call I used 'fetch('http://10.0.2.2:3000/Users)' which from what I know is the correct way to call it. When I run my react-native application to test if the connection works, I get the following error:
Error: ENOENT: no such file or directory, open 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js' at Object.openSync (node:fs:584:3) at Object.readFileSync (node:fs:452:35) at getCodeFrame (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1004:18) at Server._symbolicate (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1073:22) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Server._processRequest (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:437:7) { errno: -4058, syscall: 'open', code: 'ENOENT', path: 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js'
Has anyone got this error before and know of a a solution? Would really appreciate some help with this, I have been tried almost everything I can think of and at this point I am lost as to what I should do.
I have never seen this error before, I have looked online to see if anyone has posted a solution and found nothing, I have no idea how to solve this error, I have been debugging for hours, and have tried countless things including changing the fetch url, making a new application, etc. I know the api works because I have tested all the routes with curl, I know the fetch statements work because I created a js project and tested the fetch statements. For some reason, its just not working on my react-native application, its either giving me the above error, or if I change the url to something else like 'fetch('http://localhost:3000/Users)' it just gives me 'network connection error'.

r8xiu3jd

r8xiu3jd1#

你必须在你的电脑上创建一个wamp或nginx服务器。然后你的API项目在服务器上启动。之后,你可以访问你的pc IP地址。实际上,你的react原生模拟器在你的pc上不工作。所以你不能直接访问pc IP地址。

相关问题