havietduc91 / vuejs

Example to practice vuejs with amcharts, vue-boostrap, ag-grid, vuex, directives ..
1 stars 2 forks source link

Use export default for api function can not get data #34

Open havietduc91 opened 5 years ago

havietduc91 commented 5 years ago

If you change the bellow code, the component can not get data for ChargeList instead of

export {
  fetchChargeList,
};

to

export default {
  fetchChargeList,
};

The full code in the bellow

/**
 * Fetch charge list from api, for now just return dummy data
 *
 * @type {Promise<any>}
 */
const fetchChargeList = new Promise((resolve) => {
  setTimeout(() => {
    resolve([
      {
        cloud_account: '12314121',
        cloud_cost: '$1235.12',
        support_fee: '$1235.12',
        sales_discount: '-$40.00',
        credit: '-$10.00',
        ops_now_usage_charge: '-$10.00',
        auto_spot_usage_charge: '-$10.00',
        total: '$193.23',
      },
      {
        cloud_account: '12314122',
        cloud_cost: '$1235.12',
        support_fee: '$1235.12',
        sales_discount: '-$40.00',
        credit: '-$10.00',
        ops_now_usage_charge: '-$10.00',
        auto_spot_usage_charge: '-$10.00',
        total: '$193.23',
      },
    ]);
  }, 500);
});

export {
  fetchChargeList,
};