I have a chain promises and I want to return an object instead of a promise. Instead I get a promise. This is the function:
self.get = function(id) {
var parameters = [id];
var orders = {}
return DBA.queryAgent("SELECT * FROM Orders WHERE " + column_id + " = ?", parameters).then(function(result) {
return DBA.getById(result);
}).then(function(result) {
order = result;
return self.getProdutcs(id);
}).then(function(result) {
order.Products = result;
return order;
});
}
I expect that
service.get(1)
returns an object, I get a promise. Where am I wrong?
Thank you