Akayy
May 5, 2020, 6:48am
1
Wappler Version : 2.8.4
Operating System : Mac OSX Catalina v10.15.3
I have a dynamic API URL (see screenshot below) and when the URL is invalid:
On client-side, the API call gives me a 404 correctly
On server-side, the same API call gives me a 200 incorrectly
Something is fundamentally wrong here.
An invalid URL doesn’t have to return a 404, it depends on the remote server. In your case you with an invalid URL you will get no status code, you get a timeout error probably. I see that those are not good captured in PHP, will see if we can improve that.
In the upcoming update it will be improved. Invalid URL will return an error (500 error, not a 404) instead of 200 response.
2 Likes
Akayy
May 11, 2020, 3:28pm
5
Thanks for this fix @patrick . Just want to understand one related thing.
So, an API action with invalid URL will return an 500 error, irrespective of whether the "Pass Errors" is checked or not?
Based on your previous reply in the below thread, when Pass Errors is unchecked, we get to manage the response ourselves on front-end.
If you check the Pass Errors option then the action will stop and return the error. If you don’t check the option then you can handle the response yourself, the API step returns the status, headers and data. You can check the HTTP status if it was successfully, status 200-299 is normally successful, 400-499 are warnings and 500-599 are errors.
Not a big deal for me, but thought might help stopping "Pass Errors" checkbox becoming convoluted.
Yes, with Pass Errors
is unchecked you can handle the response yourself. You just check the status property and do your stuff depending on the status.
Akayy
May 11, 2020, 3:57pm
7
Thanks @patrick for the clarification.
Just for invalid URL alone, the error gets passed irrespective of whether the “Pass Errors” is checked or not. Hence, raised with you.
Otherwise, Pass Errors unchecked works just like how it use to:
Akayy
May 22, 2020, 12:10pm
8
bumping this so that this doesn't fall off your radar, this requires a fix...
@patrick
I have to rethink this, the Pass Errors it to pass the errors from the remote host, so when it is returning a 404 or 500 error. It was not for errors in the action file, like when having a invalid URL. It is possible to capture these with the catch in the server action and the handle it there, I’m not sure if invalid input should be seen as API errors and should be handled as if the errors came from the API.
Akayy
June 5, 2020, 3:48pm
10
Thanks for explaining @patrick , understood and agree with your logic - “Pass Errors is only to pass errors from remote host”!
Yes, it passes the errors you get from the remote api host, not the errors generated in the action.
1 Like
George
Closed
June 20, 2020, 4:00pm
14
This topic was automatically closed after 2 days. New replies are no longer allowed.