Answer the question
In order to leave comments, you need to log in
How to parse JSON response from server?
Good evening! I do not quite understand how to get the text field from json, can anyone tell me?
const requstURL = 'http://localhost:5000/main';
const sendRequst = (method, url) => {
return fetch(url).then(res => {
return res.json()
})
}
sendRequst("GET", requstURL).then(data => {
let value = JSON.stringify(data)
});
Answer the question
In order to leave comments, you need to log in
So you have already parsed json in the res.json() line and for some reason again turn it into a JSON string through stringify :)
sendRequst("GET", requstURL).then(data => {
data.forEach(item => {
console.log(item.text);
})
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question