- this is the updateUser function
const input = document.getElementById('searchForm');
const userInfoDiv = input.querySelector('#userInfomation');
const userCode = userInfoDiv.querySelector('#user_code').value;
const userName = userInfoDiv.querySelector('#username').value;
const email = userInfoDiv.querySelector('#email').value;
fetch(`{{ route('user.updateUser') }}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
body: JSON.stringify({
userCode: userCode,
username: userName,
email: email
})
})
.then(response => {
if (!response.ok) {
throw new Error('Request failed with status ' + response.status);
}
return response.json();
})
.then(data => {
console.log('Update successful:', data);
})
.catch(error => console.error('Error:', error));
}```