I have made a REST API for my react native application and want to fetch data from it, though this is not possible for me.
I have tried using localhost and ipv4 as the url, but it doesn't help at all. I also get an "Network Error" at times when I change to the different URLs, which I don't fully understand why they show up, since ipv4 or localhost should work.
I usually get a warning about the metro server after a while, if that has anything to do with it.
How can I connect my React Native client to my express backend?
try to run this command, it will link the port in you device which you run your React Native app with the port of your laptop,
"adb reverse tcp:3000 tcp:3000"
then run "react-native run-android"
i work with the port 3000, you can work with the port you want
I found the issue! I forgot a / in my base url, which broke the whole thing with axios. And I had one too many in my login post request!
Related
I'm very new to React Native and I'm understanding now Ports and similar things. In the last days I was able to access through Expo Go my app, but starting from today I ran into issues.
I think the problem was, that I was accessing the app using an university wi-fi connection, while the other days I used a mobile data connection. With Wi-Fi I was not able to access the app. The error log said: java.net.connectException: failed to connect to (...)
So I started a big journey thorugh ports, ip addresses and firewall, arriving to the ubuntu's ufw. Actually I don't know exactly what I've done, but the last try was to disable everything (like it was at the beginning) and retrying to access the app, nothing changed. The error log was: java.net.SocketTimoutException: failed to connect to (...) from (...)
I tried also use tunnel (like this question says Unable to connect to Expo React Native Project on WSL2 with Expo Go on phone) but it didn't help. In this case, the app says New update avalable: downloading... but never ends.
So, any suggestion to understand a) which is the real problem (a part that I've done something that I didn't understand) and b) how to solve it ?
It's my first time using expo for mobile development. I am trying to fetch the API from the JSON-Server but there is always the network request failed error. I have seen many posts on this issue but none of which worked for me.
What I have done:
Change to LAN connection on Expo. Start the json-server and set the host as my IPv4 address, worked on web, not on my android mobile. Also fetch http://192.xxx:3000 using the IP instead of localhost.
Change to 10.0.0.2 which should work for android emulator, but since I am using physical device. It does not work for me as well.
Change to 0.0.0.0. Does not work on both web and mobile (the endpoint is not working in the first place).
I have no ideas what else I can do now so I would like to ask if anyone knows what is happening here?
I am trying to develop React Native app using Code Server hosted in the cloud.
Is it possible to run expo with a custom domain, so I can access the link using a mobile device? By default, expo is waiting on exp://10.0.0.186:19000, and it is not accessible over the Internet.
I can specify a custom port using expo start --port XXX, but I don't know if I can specify a custom domain?
I tried using --tunnel switch, but it does not work and it outputs:
Error starting ngrok: /usr/lib/node_modules/expo-cli/node_modules/xdl/binaries/linux/adb/adb: 1: Syntax error: Unterminated quoted string
Tunnel URL not found (it might not be ready yet), falling back to LAN URL.
I am creating a React Native mobile app with storybook.js. But when I run the command yarn run storybook, the storybook server starts running on the port: 7007
Preview and components in the sidebar are not visible
but it does not show the components. But it does show the preview in android emulator.
components are visible in sidebar and visible in preview
I need to see the preview on browser, but it does not at lease show the components at least.
Can somebody please help me to solve the problem?
I had this same issue and solved it by making sure storybook and the emulator were running on the same port.
I set the port/host when configuring StorybookUIRoot then added the host to storybook command in the package.json "storybook": "start-storybook -p 7007 -h 192.168.1.8"
Restart storybook and the mobile app, you should be good to go
looks like your are experiencing a common issue. See this pinned issue from the repo.
Also to be clear the server and this web ui is not required to use react native storybook and you can use it entirely from the ondeviceUI.
There are a few things you need to do to make sure that the stories load on the server.
First you should make sure the ondevice storybook is running before you start the server.
If you are still having issues you can manually specify the port and ip address
First set the ip and port on the getStorybookUI call.
const StorybookUIRoot = getStorybookUI({
host: "192.111.1.11", // replace this ip address with your local ip address
port: "7007"
});
Then adjust the script used to launch the server to have the port and ip option. Make sure that you use exactly the same port and host that you used in the previous step otherwise it won't work.
It should look something like this but with your own IP address instead.
"storybook": "start-storybook -p 7007 -h 192.111.1.11"
If none of this helps feel free to ask questions on the storybook discord in the react-native channel and I'll be there to help you.
If you are following the storybook tutorial, try removing your yarn.lock, yarn again, and then follow Danny's answer.
Recently I started developing in react-native. When trying to debug using the react-devtools extension on the browser (Chrome) I only get access to the console, because all the components and elements are the ones displayed in the devtools web-page (http://localhost:8081/debugger-ui/)
So now I am trying using the react-native standalone version but it is "waiting for React to connect.."
and I get a message at the bottom saying "The server is listening on the port 8097".
I don't know much about ports but it looks to me that the application is on one port (8081) whereas the react-devtools is listening to another (8097).
I tried using adb reverse tcp:8097 tcp:8097 before running the react-devtools but it made no difference.
How do I check what port my app is listening to?
How can I make the standalone devtools run?
And if anyone can link me to a good documentation about ports for people with no background it would be very nice as well.
you are on the right track, after assigning port 8097.
Run Command+d to open the development menu and it is automatically detected by react-devtools.