mardi 11 mai 2021

after using pushErrors() method on changeset, the _errors property on the changeset holds an empty object

I wan to handle errors I receive from the server so when I catch one in my AJAX request I use the pushErrors() method like this:

.catch((error) => {
  let errors = get(error, 'errors');
  if (errors) errors.forEach(e => {
    changeset.pushErrors(get(e, 'fieldName'), get(e, 'fieldName') + "|" + get(e, 'constraintType') + "|" + i18n.t(get(e, 'fieldName') + get(e, 'constraintType')));
  });
});

When I check the changeset object after that the _errors property where my pushed error should have been holds an empty object. At the same time the addError() method seems to be working fine.

I use Ember version 2.16.0 and ember-changeset version 1.3.0




Aucun commentaire:

Enregistrer un commentaire