Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const getUserObject = user_id => {
- let userInfo = {};
- let ops = [
- getUser(user_id),
- getUserDetails(user_id),
- getOrders(user_id),
- getWishlist(user_id),
- ];
- return Promise.all(ops)
- .then(results => {
- userInfo = {
- "id": user_id,
- "username" : results[0].name,
- "email" : results[0].email,
- "gender" : results[1].gender,
- "age" : results[1].age,
- "state" : results[1].state,
- "orders" : [],
- "wishlist" : []
- }
- results[2].map(order => { userInfo.orders.push({ "product_id": order.product_id }) })
- results[3].map(wish => { userInfo.wishlist.push({ "product_id": wish.product_id }) })
- return userInfo
- }).catch(error => error);
- }
Add Comment
Please, Sign In to add comment