|
@@ -192,16 +192,20 @@ RNFetchBlob.fetch('GET', 'http://www.example.com/images/img1.png', {
|
192
|
192
|
Authorization : 'Bearer access-token...',
|
193
|
193
|
// more headers ..
|
194
|
194
|
})
|
195
|
|
- // when response status code is 200
|
196
|
195
|
.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
|
+ }
|
203
|
207
|
})
|
204
|
|
- // Status code is not 200
|
|
208
|
+ // Something went wrong:
|
205
|
209
|
.catch((errorMessage, statusCode) => {
|
206
|
210
|
// error handling
|
207
|
211
|
})
|