React native => axios error
Hello,
I'm trying to develop a personal project with React native with Laravel in API mode.
I just try to get some datas from the backend with axios.get(), but I get this error : Axios error - Network error, with no more details.
The backend URL is like this one : http://localhost:8000/api/recipes.
I'm using expo and I access to the application with the QR code directly on my smartphone.
What do you suggest me to check ?
Thanks for your help.
V
I just found the solution.
How foolish of me.
As the application is loaded on the smartphone, I can't use localhost given that it's not on the same computer than the backend.
So I have to specify the host when I run the php server.
php artisan serve --host=192.168.1.14
Then I just have to call the API on this address.
axios.get('http://192.168.1.14:8000/api/recipes');
@vincent15000 wow man, how foolish of me came out of my mouth too. thanks for help.
Please or to participate in this conversation.