mirror of
https://github.com/flarum/core.git
synced 2025-10-12 07:24:27 +02:00
Improve client XHR error handling
The default XHR error handler produce an alert which is appropriate to the response status code. It can be overridden per-request (by specifying the `errorHandler` option) so that the alert can be suppressed or displayed in a different position (e.g. inside a modal). ref #118
This commit is contained in:
@@ -178,7 +178,8 @@ export default class SignUpModal extends Modal {
|
||||
app.request({
|
||||
url: app.forum.attribute('baseUrl') + '/register',
|
||||
method: 'POST',
|
||||
data
|
||||
data,
|
||||
errorHandler: this.onerror.bind(this)
|
||||
}).then(
|
||||
payload => {
|
||||
const user = app.store.pushPayload(payload);
|
||||
@@ -190,14 +191,10 @@ export default class SignUpModal extends Modal {
|
||||
window.location.reload();
|
||||
} else {
|
||||
this.welcomeUser = user;
|
||||
this.loading = false;
|
||||
m.redraw();
|
||||
this.loaded();
|
||||
}
|
||||
},
|
||||
response => {
|
||||
this.loading = false;
|
||||
this.handleErrors(response);
|
||||
}
|
||||
this.loaded.bind(this)
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user