-
Notifications
You must be signed in to change notification settings - Fork 1.6k
How to catch a 404 when fetching an image, current .catch example does not work? #267
Comments
@lakhman , you can find the status code via res.info(), it's a RNFetchBlobResponseInfo object. |
Correct me if I'm wrong, but I think what @lakhman means is that the .catch() block isn't firing. I'm running into the same problem. I have a call that's returning a 401. I'm able to validate it through a curl call. However, RNFetchBlob always executes the .then() block and never jumps to the catch() even though it's not a 200 status.
|
The library will not throw an error because it's a successful request, just like how fetch treats the 4xx response. Catch block will only execute when network error happens. |
@wkh237 that worked, perhaps the docs could be updated to provide a clearer example, I think catching 404 missing images would be a common use case and would help others! +1 Thanks |
Just stumbled upon this, I think the documentation need updating. This example says the |
Hi,
I make a fetch for a image like so:
The server i'm fetching from returns the correct headers and status code (from chrome:)
Instead, it saves the returned 404 HTML content into a file (
fileCache: true
)./Users/user/Library/Developer/CoreSimulator/Devices/.../data/Containers/Data/Application/.../Documents/RNFetchBlob_tmp/
Am I doing something wrong? or is this a bug?
I should add:
I'm on iOS - Simulator - 10.2
Fetch Blob Version: ^0.10.2
The text was updated successfully, but these errors were encountered: