Hi,

I'm trying to launch asynchronous method on serie way with async, But, you 
guess it, I can't did it.
Here is my code :

function findParam(userKey,callback){
    console.log("looking for params "+userKey);
    params.get(userKey,
        function(err, result, key) {
            var param = result;
            param.key=key;
            console.log("findParam "+param);
            callback(err, userKey, param);
        });
    console.log("done");
}

function findUsers(userKey,param, callback){
    console.log("looking fo uers "+userKey);
    console.log("Param "+param);
    users.get(userKey,
        function(err, result, key) {
            var user = result;
            user.key=key;
            console.log("user "+user);
            callback(err, user, param);
        });
}

launch code :

var user = findUserBySession(req.sessionID);
    async.waterfall(
        [
            findParam(user.key, callback),
            findUsers(arg1, arg2, callback)
        ]);

the stack trace :
looking for params 3edgl89
done
ReferenceError: arg1 is not defined... (lot of errors)
findParam [object Object]

That stack trace revealed to me that the second method is launched before 
the param was found. This is why the error appeared.
Can you help me ? What have I done wrong ?

Thank you !

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/996994b1-70a5-444b-9c07-a2e9e09a935d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to