mercredi 28 janvier 2015

How to pass parameter into a function in my case


I am trying to build promises for my app. I have something like



var test = function(id,companyID) {
return getProduct(id)
.then(getProductName(companyID))
.then(function(obj) {
console.log(obj)
})
}

test('123', '456');


All I can see is an object that contain empty contexts. However, if I change my code to no include the parameters and hardcode in the getProductName function like



var test = function(id,companyID) {
return getProduct(id)
.then(getProductName)
.then(function(obj) {
console.log(obj)
})
}

test('123', '456');


I got the data I need in the console.log


I am not sure how to pass an parameters into the chain. Any idea how to do it? Thanks a lot!





Aucun commentaire:

Enregistrer un commentaire