Fetching AJAX results from three endpoints, with error handling
I would suggest passing in an array of endpoints so you can have one loop that calls an endpoint and looks at the result without repeating any code:

function checkForData(endPoints) {
    let i = 0;

    function next() {
        if (i &lt; endPoints.length) {
            return myAjaxFunction(endPoints[i++]).then(function(data) {
                if (data &amp;&amp; data.d &amp;&amp; data.d.results &amp;&amp; data.d.results.length &gt; 0) {
                    return data.d.results;
                } else {
                    return next();
                }
            });
        } else {
            return null;
        }
    }

    return Promise.resolve().then(next);
}

checkForData([endPoint1, endPoint2, endPoint3]).then(function(result) {
    // result here
    if (result) {
        console.log(result);
    } else {
        console.log("no data found");
    }
}).catch(function(err) {
    // error here
});


Note: I also put .then() on the same line as its parent function to avoid an extra level of indent.