I have a working post method for storing a photo + the first name of the user.
// front-end
let formData = new FormData();
formData.append('photo', this.tableItem.photo);
formData.append('first_name', this.tableItem.first_name);
await axios.post('/api/employees', formData, { headers: { 'Content-Type': 'multipart/form-data' }})
// back-end
$employee = Employee::create([
'first_name' => $request->first_name,
]);
Now if I edit the first_name, the put method is a success but the value is displayed as blank
Object.assign(this.tableData[this.editedIndex], this.tableItem)
let formData = new FormData();
formData.append('photo', this.tableItem.photo);
formData.append('first_name', this.tableItem.first_name);
await axios.put('/api/employees/' + this.tableItem.id, formData, { headers: { 'Content-Type': 'multipart/form-data' }})
$employee->update([
'first_name' => $request->first_name,
]);
If I removed the formData and replaced it with this.tableItem everything is working as intended. Even if a I put an await for Object.assign, the new value input is still not captured.