Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  mounted() {
  2.            var orders = [];
  3.            var ordersPopulated = [];
  4.                 if(this.$session.get('token') == null){
  5.                     this.$router.push('../login');
  6.                     return;
  7.                 }
  8.                 this.$http.post('http://localhost:3000/order/getOrders/', {
  9.                     auth: {
  10.                         token: this.$session.get('token'),
  11.                         userID: this.$session.get('userID'),
  12.                         isAdmin: this.$session.get('isAdmin')
  13.                     },
  14.                     showAll: false
  15.                 }).then(function(data) {
  16.                     if(data.body.code != null){
  17.                         this.$router.push('../login');
  18.                     }else{
  19.                         orders = data.body;
  20.                         console.log("orders")
  21.                         console.log(orders)
  22.                         for(var i = 0, len = orders.length; i <= len; i++) {
  23.                             this.$http.post('http://localhost:3000/product/info', {
  24.                                 //jsonBody
  25.                                 id: orders[i].productID
  26.                             }).then(function(data) {
  27.                                 if (!data.body.code == 200) {
  28.                                     return;
  29.                                 }
  30.                                 else {
  31.                                     console.log(orders[i])
  32.                                     ordersPopulated.push(orders[i]);
  33.                                     ordersPopulated[i].productName = data.body.productName;
  34.                                     ordersPopulated[i].productDesc = data.body.productDesc;
  35.                                     ordersPopulated[i].productImg = data.body.productImg;
  36.                                     ordersPopulated[i].productPrice = data.body.productPrice;
  37.                                 }
  38.                                 //ordersPopulated.push(orders[i]);
  39.                             });
  40.                         }
  41.                         this.orders = ordersPopulated;
  42.                     }
  43.                 });
  44.  
  45.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement