Hi!
I have a post object on server which contains array of likes
how do I increase or decrease its length with fetch put method?
export function addLike() {
fetch(
"https://nomoreparties.co/v1/" +
`${cohortId}` +
"/cards" +
"/" +
`cardNumber`,
{
method: "PUT",
headers: apiConfig.headers,
body: JSON.stringify({
_id: apiConfig.id,
likes: likes.push(1),
}),
}
)
.then((response) => response.json())
.then((json) => console.log(json));
}
When I call this function I get Uncaught ReferenceError: likes is not defined, but it’s there! The idea was to push one random element to likes array to increase it’s length(likes count)