user7254108
user7254108

Reputation:

Why do I receive a promise pending message?

Im trying to assign a variable of function.

This returned promise pending.

im = app.service('/messages').find({
    default: 5,
    max: 4,
    query: {
        $skip: 9,
        $limit: 5
    }
});
console.log(im);

Upvotes: 0

Views: 207

Answers (1)

Finn
Finn

Reputation: 2775

This related to async processing in Javascript, you need to wait for the result and assign it to im. You can read the document of app.service to find where is the callback of find function. The code below just assume that the callback next to the parameter.

app.service('/messages').find({
    default: 5,
    max: 4,
    query: {
        $skip: 9,
        $limit: 5
    }
}, function(error, result){
    im = result;
    console.log(im);
});

Upvotes: 1

Related Questions