nativescript-community / https

Secure HTTP client with SSL pinning for Nativescript - iOS/Android
https://nativescript-community.github.io/https/
Other
51 stars 42 forks source link

[IOS] Keeping content the same on AFSuccess and AFFailure #63

Closed kefahB closed 4 years ago

kefahB commented 4 years ago

Hi @EddyVerbruggen

There is inconsistency between AFSuccess and AFFailure on the response .. of course I understand it is not the same .. but when dealing with REST API we expecting to get sometimes status response like 301 or 422... the problem it is the AFFailure return the content in a new object content.body .. when trying to do some check stuff, we xill need a lot of change in ours code to change response.content to `response.content.body'

I added a new objet 'failureinstead ofcontent` and keeping content he same as AFSuccess.

let failure: any = {
    body: content,
    description: error.description,
    reason: error.localizedDescription,
    url: error.userInfo.objectForKey('NSErrorFailingURLKey').description
  };

  resolve({task, content, reason, failure: failure});