0

I am using AFNetworking, Overcoat and Promisekit. I would like to see the json that I am getting back from the server.

//apiclient.h
@interface STRAPIClient : OVCHTTPSessionManager

//apiclient.m
[self POST:@"contents" parameters:parameters]
    .then(^(OVCResponse *response) {
      return response.result;
    })
    .catch(^(NSError * error){
        NSLog(error.description);
    });;

How do i get the response string from the NSError object?

meow
  • 27,476
  • 33
  • 116
  • 177
  • What response are you referring to? If the error corresponds to a network error then you'd have no response. – Cristik Apr 24 '15 at 18:27
  • sorry, i clarified. i am referring to json string the server is returning – meow Apr 25 '15 at 00:00

1 Answers1

0

Check error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey] and error.userInfo[AFNetworkingOperationFailingURLResponseErrorKey].

From AFURLResponseSerialization.h:

Constants

AFNetworkingOperationFailingURLResponseErrorKey
The corresponding value is an NSURLResponse containing the response of the operation associated with an error. This key is only present in the AFURLResponseSerializationErrorDomain.

AFNetworkingOperationFailingURLResponseDataErrorKey
The corresponding value is an NSData containing the original data of the operation associated with an error. This key is only present in the AFURLResponseSerializationErrorDomain.

Cristik
  • 30,989
  • 25
  • 91
  • 127