Skip to content

Commit a3cf145

Browse files
authored
Merge pull request #57 from guimeira/master
Update README with proper status code handling
2 parents fa38cd5 + 393c668 commit a3cf145

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,20 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
192192
Authorization : 'Bearer access-token...',
193193
// more headers ..
194194
})
195-
// when response status code is 200
196195
.then((res) => {
197-
// the conversion is done in native code
198-
let base64Str = res.base64()
199-
// the following conversions are done in js, it's SYNC
200-
let text = res.text()
201-
let json = res.json()
202-
196+
let status = res.info().status;
197+
198+
if(status == 200) {
199+
// the conversion is done in native code
200+
let base64Str = res.base64()
201+
// the following conversions are done in js, it's SYNC
202+
let text = res.text()
203+
let json = res.json()
204+
} else {
205+
// handle other status codes
206+
}
203207
})
204-
// Status code is not 200
208+
// Something went wrong:
205209
.catch((errorMessage, statusCode) => {
206210
// error handling
207211
})

0 commit comments

Comments
 (0)