Closed kefahB closed 4 years ago
If you think that will affect the others .. we can add a new options :
{
useLegacy: true // default (false) the AFFailure will return the "old" system, set to true to get the new retrun
}
// in AFFailure function add
function AFFailure(resolve, reject, task: NSURLSessionDataTask, error: NSError) {
// ... (code)
if(this.opts.useLegacy) {
let failure: any = {
body: content,
description: error.description,
reason: error.localizedDescription,
url: error.userInfo.objectForKey('NSErrorFailingURLKey').description
};
if (policies.secured === true) {
failure.description = 'nativescript-https > Invalid SSL certificate! ' + error.description;
}
let reason = error.localizedDescription;
resolve({task, content, reason, failure: failure});
} else {
let content: any = {
body,
description: error.description,
reason: error.localizedDescription,
url: error.userInfo.objectForKey('NSErrorFailingURLKey').description
};
if (policies.secured === true) {
content.description = 'nativescript-https > Invalid SSL certificate! ' + content.description;
}
let reason = error.localizedDescription;
resolve({task, content, reason});
}
}
Hi @EddyVerbruggen .. what do you think about this PR ?
Hi @EddyVerbruggen,
I hope you have good health you and your family !
Any chance to view this please ?
Sorry for the delay my man! All is well over here, hope you and your loved ones are safe too!
I've merged and published your PR (v 2.1.0).
All the best, Eddy
Hi @EddyVerbruggen
There is inconsistency between
AFSuccess
andAFFailure
on the response .. of course I understand it is not the same .. but when dealing withAPI REST
we expecting to get sometimes status response like301
or422
... the problem it is theAFFailure
return the content in a new objectcontent.body
.. when trying to do some check stuff, we need a lot of change in our code to changeresponse.content
toresponse.content.body
I added a new objet
failure
instead ofcontent
and keeping content he same as AFSuccess.