function updateItem() {
const itemId = document.getElementById('edit-id').value;
const item = {
id: parseInt(itemId, 10),
name: document.getElementById('edit-name').value.trim(),
description: document.getElementById('edit-desc').value.trim(),
countryID: document.getElementById('edit-coid').value.trim()
};
fetch(`${uri}/${itemId}` + "?UserName=" + UserName, {
method: 'PUT',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify(item)
})
.then(() => getItems())
.catch(error => console.error('Unable to update item.', error));
closeInput();
return false;
}
#JS: My API update PUT function is giving a 400 error when reaching Fetch()
4 messages · Page 1 of 1 (latest)