Skip to content

Commit

Permalink
Merge pull request #57 from guimeira/master
Browse files Browse the repository at this point in the history
Update README with proper status code handling
  • Loading branch information
Traviskn committed Jun 2, 2018
2 parents fa38cd5 + 393c668 commit a3cf145
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,20 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
Authorization : 'Bearer access-token...',
// more headers ..
})
// when response status code is 200
.then((res) => {
// the conversion is done in native code
let base64Str = res.base64()
// the following conversions are done in js, it's SYNC
let text = res.text()
let json = res.json()

let status = res.info().status;

if(status == 200) {
// the conversion is done in native code
let base64Str = res.base64()
// the following conversions are done in js, it's SYNC
let text = res.text()
let json = res.json()
} else {
// handle other status codes
}
})
// Status code is not 200
// Something went wrong:
.catch((errorMessage, statusCode) => {
// error handling
})
Expand Down

0 comments on commit a3cf145

Please sign in to comment.