i have one of those api's mywebsite/api/do-something it usually returns a json encoded data which i decode in my app return json_encode(['success' => true, 'message' => $message]); the problem is if something crashes in the api request i dont see the error it just tells me Exception occurred: DioException [bad response]: This exception was thrown because the response has a status code of 500 and RequestOptions.validateStatus was configured to throw for this status code. I/flutter (17906): The status code of 500 has the following meaning: "Server error - the server failed to fulfil an apparently valid request" i wish i could get the actual error or the line that is causing error to be sent to me how do i fetch errors from my api's thank you
#Handling error in your API's
11 messages · Page 1 of 1 (latest)
So first of all, why not just follow the docs on how to do proper JSON responses; https://laravel.com/docs/11.x/responses#json-responses?
Secondly, you're receiving a 500 response, which is an error in your application. So look at the logs what kind of error you're making
@chilly trout it's not an error in the app because the beginning part of the request completes then it reaches a point and break I want to see that point that's why
The job of the app is just to send a post request with data those data actually went through but something spoilt in my Laravel code
I guess read the Flutter docs? I mean, that error seems to originate from Flutter, because you're making a request in Flutter, which then responds with a 500.
If I return a response in some part of my Laravel code that error won't show until I reach the reach the part where the Laravel code saves the data then it breaks
Then again, if it's a 500 from your Laravel app, it would probably end up in your logs. Unless you're doing something like a dd(), which would just return a 500 response with that as a body. And yeah, that's up to whatever you're using to make the request, if that can't show the request there's not much that Laravel can do.
Ah I see in my logs thanks it showed there
That's what I first mentioned, but glad you found it