From 2dbf0d452a3c70528c93a302855a2d168d1f1ea9 Mon Sep 17 00:00:00 2001 From: Raman Rasliuk Date: Tue, 27 Feb 2018 12:04:37 +0100 Subject: [PATCH] App Crash on error body does not exists Prevent crash if body does not exist on error --- src/ios/CordovaHttpPlugin.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ios/CordovaHttpPlugin.m b/src/ios/CordovaHttpPlugin.m index bff6a3f..bc9942e 100644 --- a/src/ios/CordovaHttpPlugin.m +++ b/src/ios/CordovaHttpPlugin.m @@ -69,7 +69,9 @@ [dictionary setValue:response.URL.absoluteString forKey:@"url"]; [dictionary setObject:[NSNumber numberWithInt:(int)response.statusCode] forKey:@"status"]; [dictionary setObject:[self copyHeaderFields:response.allHeaderFields] forKey:@"headers"]; - [dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey] forKey:@"error"]; + if (error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey]) { + [dictionary setObject:error.userInfo[AFNetworkingOperationFailingURLResponseBodyKey] forKey:@"error"]; + } } else { [dictionary setObject:[self getStatusCode:error] forKey:@"status"]; [dictionary setObject:[error localizedDescription] forKey:@"error"];