0👍
✅
The problem came from the call to axios.post
.
The second argument for post, put and patch is the data, and the third is the options.
The options were send as data, which wasn’t correct, obviously.
The correct way to do it is to create a set of data (either by creating a json string, or by using URLSearchParams
) and place it as second argument of post call.
const params = new URLSearchParams();
params.append('firstName', this.currentUser.firstName);
params.append('lastName', this.currentUser.lastName);
params.append('email', this.currentUser.email);
params.append('profile', this.currentUser.profileId);
axios.post('/admin/user',
params,
{headers: {'Authorization': 'Bearer ' + localStorage.getItem('auth_token')}});
Source:stackexchange.com