Update app.request calls to use 'body' instead of 'data' for form data

This commit is contained in:
David Sevilla Martin 2019-12-16 18:25:39 -05:00
parent 48dccda707
commit 2fd3aa8c71
No known key found for this signature in database
GPG Key ID: F764F1417E16B15F
5 changed files with 12 additions and 12 deletions

View File

@ -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);

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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)

View File

@ -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'
});
}