Answer the question
In order to leave comments, you need to log in
TypeError: update.json is not a function?
When sending, a TypeError error pops up: update.json is not a function, if you refresh the page, the data is still updated, the fetch works. But with this error... const result = await update.json();
async function update() {
const id = document.getElementById('id ').value,
title = document.getElementById('title ').value,
body = document.getElementById('body ').value;
if (title == '' || body == '') {
return;
}
const data = {
title: title,
body: body
};
const update = fetch(`http://pathTo/up/${id}`, {
method: 'PATCH',
body: JSON.stringify(data)
});
const result = await update.json();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question