조건이 충족되는 특정 수의 행만로드하고 싶습니다.
그러나 다음 코드는 25 개 행을 모두 가져오고 조건이 작동하지 않습니다.
누군가 도와주세요.
loadCommentsFromServer = () => {
fetch('/api/comments/', {
method: 'GET',
author: 'Dani'
})
.then(data => data.json())
.then((res) => {
if (!res.success) this.setState({ error: res.error });
else this.setState({ data: res.data });
});
}
나는 자바 스크립트와 reactjs를 처음 접했고 어떤 도움도 주말을 절약 할 수 있습니다.
두 번째 콜백의 응답에 액세스 할 수 없습니다.
loadCommentsFromServer = () => {
return fetch('/api/comments/', {
method: 'GET',
author: 'Dani'
})
.then((res) => {
if (!res.success) this.setState({ error: res.error });
else res.json().then(data => this.setState({ data }));
});
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다