Skip to content Skip to sidebar Skip to footer

How To Fix My Promise Return Here For This Function?

I have an array of tags which may contain up to 3 items. Next I pass tags into my getTagQuotes function and am trying to set a promise variable to it. Right now I'm getting promise

Solution 1:

Your getTagQuotes function should return a promise with the $q service, check it out.

It should look like this:

function getTagQuotes(tags) {
    var deferred = $q.defer();

    (...)
    // When the action is finished here, call resolve:
    deferred.resolve();
    (...)

    // And in the end, return the promise
    return deferred.promise;
}

And finally, in your main code, you'll do:

var promise = getTagQuotes(tags).then(function(){
    console.log('promise =',promise);
    // Fill chartObj with tweet data arrays
    (...)
});

Solution 2:

This function has no return statement.

function getTagQuotes(tags)

Post a Comment for "How To Fix My Promise Return Here For This Function?"