Answer the question
In order to leave comments, you need to log in
How to change data on the server?
Good afternoon! I am working on one web application on a fake "Json - server".
I had such a problem, because I'm using the PATCH method for the first time, I can't change the data on the server, it gives a 400 error in the console, and the browser gives the error "TypeError: Cannot read property 'type' of undefined".
I'll attach the code below
.
export const editChannel = (name, login, link, followers, desk, id) => {
fetch(`http://localhost:3001/channels/${id}`,{
method: 'PATCH',
body: {
name: name,
channelLogin: login,
imgUrl: link,
followers: followers,
desk: desk
},
headers: {
'Content-type': 'application/json; charset=UTF-8'
},
})
.then(res => res.json())
.then(json => {
console.log(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