Using 10.0.2.2
instead of localhost
or 127.0.0.1
make sense when you are using emulator.
But It’s expected that you can’t connect to the localhost
being not in the same network.
You can share hotspot from your desktop, connect mobile to it and use your IP in this network (most probable 192.168.137.1
) instead of localhost
. Or find another variant.
So for our application end points(laravel)
http://192.168.0.243:8000/api/v1/products/popular
In this case, you need to find the IP address of your computer.
or
http://10.0.2.2:8000/api/v1/products/popular
So for android use this
Localhost for android is emulator 127.0.0.1 => 10.0.2.2