mirror of
https://github.com/flarum/core.git
synced 2025-08-04 23:47:32 +02:00
Update app.request calls to use 'body' instead of 'data' for form data
This commit is contained in:
@@ -147,7 +147,7 @@ export default class Model {
|
|||||||
return app.request(Object.assign({
|
return app.request(Object.assign({
|
||||||
method: this.exists ? 'PATCH' : 'POST',
|
method: this.exists ? 'PATCH' : 'POST',
|
||||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||||
data: request
|
body: request
|
||||||
}, options)).then(
|
}, options)).then(
|
||||||
// If everything went well, we'll make sure the store knows that this
|
// If everything went well, we'll make sure the store knows that this
|
||||||
// model exists now (if it didn't already), and we'll push the data that
|
// model exists now (if it didn't already), and we'll push the data that
|
||||||
@@ -176,13 +176,13 @@ export default class Model {
|
|||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
delete(data, options = {}) {
|
delete(body, options = {}) {
|
||||||
if (!this.exists) return m.deferred.resolve().promise;
|
if (!this.exists) return m.deferred.resolve().promise;
|
||||||
|
|
||||||
return app.request(Object.assign({
|
return app.request(Object.assign({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||||
data
|
body
|
||||||
}, options)).then(() => {
|
}, options)).then(() => {
|
||||||
this.exists = false;
|
this.exists = false;
|
||||||
this.store.remove(this);
|
this.store.remove(this);
|
||||||
|
@@ -27,7 +27,7 @@ export default class Session {
|
|||||||
login(body: { identification: string, password: string }, options = {}) {
|
login(body: { identification: string, password: string }, options = {}) {
|
||||||
return app.request(Object.assign({
|
return app.request(Object.assign({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: app.forum.attribute('baseUrl') + '/login',
|
url: `${app.forum.attribute('baseUrl')}/login`,
|
||||||
body
|
body
|
||||||
}, options));
|
}, options));
|
||||||
}
|
}
|
||||||
|
@@ -78,13 +78,13 @@ export default class Store {
|
|||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
find<T extends Model = Model>(type: string, id?: number|number[]|any, query = {}, options = {}): Promise<T[]> {
|
find<T extends Model = Model>(type: string, id?: number|number[]|any, query = {}, options = {}): Promise<T[]> {
|
||||||
let data = query;
|
let body = query;
|
||||||
let url = `${app.forum.attribute('apiUrl')}/${type}`;
|
let url = `${app.forum.attribute('apiUrl')}/${type}`;
|
||||||
|
|
||||||
if (id instanceof Array) {
|
if (id instanceof Array) {
|
||||||
url += `?filter[id]=${id.join(',')}`;
|
url += `?filter[id]=${id.join(',')}`;
|
||||||
} else if (typeof id === 'object') {
|
} else if (typeof id === 'object') {
|
||||||
data = id;
|
body = id;
|
||||||
} else if (id) {
|
} else if (id) {
|
||||||
url += `/${id}`;
|
url += `/${id}`;
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ export default class Store {
|
|||||||
return app.request(Object.assign({
|
return app.request(Object.assign({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url,
|
url,
|
||||||
data
|
body
|
||||||
}, options)).then(this.pushPayload.bind(this));
|
}, options)).then(this.pushPayload.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -158,7 +158,7 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||||||
if (this.loading) return;
|
if (this.loading) return;
|
||||||
|
|
||||||
const user = this.props.user;
|
const user = this.props.user;
|
||||||
const data = new FormData();
|
const body = new FormData();
|
||||||
data.append('avatar', file);
|
data.append('avatar', file);
|
||||||
|
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@@ -166,9 +166,9 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||||||
|
|
||||||
app.request({
|
app.request({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar',
|
url: `${app.forum.attribute('apiUrl')}/users/${user.id()}/avatar`,
|
||||||
serialize: raw => raw,
|
serialize: raw => raw,
|
||||||
data
|
body
|
||||||
}).then(
|
}).then(
|
||||||
this.success.bind(this),
|
this.success.bind(this),
|
||||||
this.failure.bind(this)
|
this.failure.bind(this)
|
||||||
@@ -186,7 +186,7 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||||||
|
|
||||||
app.request({
|
app.request({
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar'
|
url: `${app.forum.attribute('apiUrl')}/users/${user.id()}/avatar`
|
||||||
}).then(
|
}).then(
|
||||||
this.success.bind(this),
|
this.success.bind(this),
|
||||||
this.failure.bind(this)
|
this.failure.bind(this)
|
||||||
|
@@ -193,7 +193,7 @@ export default class NotificationList extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.request({
|
app.request({
|
||||||
url: app.forum.attribute('apiUrl') + '/notifications/read',
|
url: `${app.forum.attribute('apiUrl')}/notifications/read`,
|
||||||
method: 'POST'
|
method: 'POST'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user