Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

Good Day, I am a beginner in android development and laravel. I am creating a mobile-web application. I am using laravel in my Web app and I have this problem on generating the url that I should use when I retrieve json data for my android app. When I run it on localhost (http://localhost:8000/getAllLocations), I can view the json. but when I run it in using my ip address (192.168.x.xx/getAllLocations), it gives me an Object not found error.

Below are screenshots of my controller, route.php, the json result that I want to get, and the error I got after using the url: 192.168.x.xx/getAllLocations.

Please help me.

Here is my controller

Here is my route.php

Here is a screenshot of the result that I want to get with my android app. I got these after running localhost:8000/getAllLocations

This is what I got when I try to retrieve the json data using my IP address instead of localhost in the url.

share|improve this question

put on hold as off-topic by Deduplicator, PetahChristian, davidism, Carl Veazey, Petr 4 hours ago

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – Deduplicator, PetahChristian, davidism, Carl Veazey, Petr
If this question can be reworded to fit the rules in the help center, please edit the question.

Please post the code. –  Bogdan Oct 3 at 7:49
When you use localhost, are you using Xamp, or php artisan serve? Are you sure it's not in a subdirectory like 192.x.x.x/locationapp/getAllLocations? –  sniels Oct 3 at 23:40
I think you'll be OK if you do as @sniels suggested. You might have to try x.x.x.x/Advision/public/getAllLocation though I believe.... If that works, you should be able to change the httpd.conf file to point directly to the public folder without "Advision/public" being needed in the URL, but one step a time. –  dangel Oct 4 at 1:12
awesome! after all of these years of taking advantage of SO by asking questions, I'm glad to finally be able to give something back and help someone –  dangel Oct 4 at 1:18
@sniels Yes! I just tried dangel's suggestion a minute ago and I got the json data. Thank you so much for the help :D –  Airam Ashiya Oct 4 at 1:18

1 Answer 1

up vote 1 down vote accepted

Airam Ashiya, I'm betting that you have some issue with the xampp configuration. But we need more information on your dev environment to understand the source of the issue.

Airam Ashiya, I would like to give you a quick advice: you should not use a ip to access your web app, you should really use a "local domain" to mimic the production environment (this is not consensual, but I found this to be the best way to maintain some "url sanity"). Check this articles on how to set it up: Use custom domains on Xammp + How to edit the host file on android


share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.