mirror of
https://github.com/flarum/framework.git
synced 2025-02-17 02:02:47 +08:00
Update app.request calls to use 'body' instead of 'data' for form data
This commit is contained in:
parent
48dccda707
commit
2fd3aa8c71
|
@ -147,7 +147,7 @@ export default class Model {
|
|||
return app.request(Object.assign({
|
||||
method: this.exists ? 'PATCH' : 'POST',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
data: request
|
||||
body: request
|
||||
}, options)).then(
|
||||
// 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
|
||||
|
@ -176,13 +176,13 @@ export default class Model {
|
|||
* @return {Promise}
|
||||
* @public
|
||||
*/
|
||||
delete(data, options = {}) {
|
||||
delete(body, options = {}) {
|
||||
if (!this.exists) return m.deferred.resolve().promise;
|
||||
|
||||
return app.request(Object.assign({
|
||||
method: 'DELETE',
|
||||
url: app.forum.attribute('apiUrl') + this.apiEndpoint(),
|
||||
data
|
||||
body
|
||||
}, options)).then(() => {
|
||||
this.exists = false;
|
||||
this.store.remove(this);
|
||||
|
|
|
@ -27,7 +27,7 @@ export default class Session {
|
|||
login(body: { identification: string, password: string }, options = {}) {
|
||||
return app.request(Object.assign({
|
||||
method: 'POST',
|
||||
url: app.forum.attribute('baseUrl') + '/login',
|
||||
url: `${app.forum.attribute('baseUrl')}/login`,
|
||||
body
|
||||
}, options));
|
||||
}
|
||||
|
|
|
@ -78,13 +78,13 @@ export default class Store {
|
|||
* @param options
|
||||
*/
|
||||
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}`;
|
||||
|
||||
if (id instanceof Array) {
|
||||
url += `?filter[id]=${id.join(',')}`;
|
||||
} else if (typeof id === 'object') {
|
||||
data = id;
|
||||
body = id;
|
||||
} else if (id) {
|
||||
url += `/${id}`;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ export default class Store {
|
|||
return app.request(Object.assign({
|
||||
method: 'GET',
|
||||
url,
|
||||
data
|
||||
body
|
||||
}, options)).then(this.pushPayload.bind(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||
if (this.loading) return;
|
||||
|
||||
const user = this.props.user;
|
||||
const data = new FormData();
|
||||
const body = new FormData();
|
||||
data.append('avatar', file);
|
||||
|
||||
this.loading = true;
|
||||
|
@ -166,9 +166,9 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||
|
||||
app.request({
|
||||
method: 'POST',
|
||||
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar',
|
||||
url: `${app.forum.attribute('apiUrl')}/users/${user.id()}/avatar`,
|
||||
serialize: raw => raw,
|
||||
data
|
||||
body
|
||||
}).then(
|
||||
this.success.bind(this),
|
||||
this.failure.bind(this)
|
||||
|
@ -186,7 +186,7 @@ export default class AvatarEditor extends Component<AvatarEditorProps> {
|
|||
|
||||
app.request({
|
||||
method: 'DELETE',
|
||||
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar'
|
||||
url: `${app.forum.attribute('apiUrl')}/users/${user.id()}/avatar`
|
||||
}).then(
|
||||
this.success.bind(this),
|
||||
this.failure.bind(this)
|
||||
|
|
|
@ -193,7 +193,7 @@ export default class NotificationList extends Component {
|
|||
});
|
||||
|
||||
app.request({
|
||||
url: app.forum.attribute('apiUrl') + '/notifications/read',
|
||||
url: `${app.forum.attribute('apiUrl')}/notifications/read`,
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user