Nicer code for showing API error message

[MAILPOET-2316]
This commit is contained in:
Ján Mikláš
2019-09-03 16:11:22 +02:00
committed by Jack Kitterhing
parent 4d931bfb0e
commit ed971dd4dd

View File

@@ -239,16 +239,9 @@ const itemActions = [
data: {
id: subscriber.id,
},
}).done(() => {
MailPoet.Notice.success(MailPoet.I18n.t('oneConfirmationEmailSent'));
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => error.message),
{ scroll: true }
);
}
});
})
.done(() => MailPoet.Notice.success(MailPoet.I18n.t('oneConfirmationEmailSent')))
.fail((response) => MailPoet.Notice.showApiErrorNotice(response));
},
},
{