There is a funcion returning a promise:
req.postP = function () {
var $promise = $.ajax({
url: self._url(url),
type: "POST",
data: JSON.stringify(data),
headers: headers,
contentType: self.JSON_CONTENT_TYPE,
dataType: "json"
});
return new Promise( (resolve, reject) => {
return $promise.then(resolve, reject);
} );
}
And another function that calls the first function:
req
.postP(POST_REGISTER, userData)
.then((data) => {
// is never ecexuted
})
.catch((err) => {
console.log(typeof err.then === "function"); // true
});
The then()
function is never executed.
It seems that the promise is inside the catch function as err
since err.then
is a function.
The req.postP()
function is called by other function as well and works in those cases.