mirror of
https://github.com/flarum/core.git
synced 2025-10-11 06:54:26 +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:
@@ -79,10 +79,11 @@ export default class Store {
|
||||
* Alternatively, if an object is passed, it will be handled as the
|
||||
* `query` parameter.
|
||||
* @param {Object} [query]
|
||||
* @param {Object} [options]
|
||||
* @return {Promise}
|
||||
* @public
|
||||
*/
|
||||
find(type, id, query = {}) {
|
||||
find(type, id, query = {}, options = {}) {
|
||||
let data = query;
|
||||
let url = app.forum.attribute('apiUrl') + '/' + type;
|
||||
|
||||
@@ -94,11 +95,11 @@ export default class Store {
|
||||
url += '/' + id;
|
||||
}
|
||||
|
||||
return app.request({
|
||||
return app.request(Object.assign({
|
||||
method: 'GET',
|
||||
url,
|
||||
data
|
||||
}).then(this.pushPayload.bind(this));
|
||||
}, options)).then(this.pushPayload.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user