lundi 15 mai 2017

Ember model addObject not a function

I get "application.js:72 TypeError: _this2.get(...).toArray is not a function" error in the following code. I am trying to push what comes from the server response to the model so that model is dynamically updated. This is happening in controller. Controller intercepts an action from another component in the template. What is going wrong here?

actions: {
sendData: function () {
  this.set('showLoading', true);

  let data = {
    startTime: date.normalizeTimestamp(this.get('startTimestamp')),
    endTime: date.normalizeTimestamp(this.get('endTimestamp')),
    type: constants.ENTERPRISE.REPORTING_PAYMENT_TYPE
  };

  api.ajaxPost(`${api.buildV3EnterpriseUrl('reports')}`, data).then(response => {
    this.set('showLoading', false);

    console.log("Comes here!!!!");
    console.log(this.get('model'));
    this.get('model').toArray().addObject(Ember.Object.create(response));

    return response.report;
  }).catch(error => {
    this.set('showLoading', false);
    if (error.status === constants.HTTP_STATUS.GATEWAY_TIMEOUT) {
      this.notify.error(this.translate('reports.report_timedout'), this.translate('reports.report_timedout_desc'));
    } else {
      this.send('error', error);
    }
  });
}




Aucun commentaire:

Enregistrer un commentaire