var wasAuth = new Promise(
function (resolve, reject) {
fetch('ajax.php')
.then(function(response) {
return response.json();
})
.then(function(res) {
resolve("Auth == true");
// OR
reject(new Error("Auth == false"));
})
.catch(alert);
}
);
var sell = function () {
wasAuth
.then(function (fulfilled) {
console.log(fulfilled); // Auth == true
})
.catch(function(error) {
console.log(error.message); // Auth == false
});
};
sell();