리액트 강의 잘 듣고 있습니다.
react-query 배우고 있는데요.
let result = useQuery('작명', () => {
axios.get('https://codingapple1.github.io/userdata.json')
.then((a) => {
return a.data
})
})
이렇게 했을 때 get 요청으로 얻은 데이터의 이름을 result.data.name로 볼 수 있다고 하셨는데
{ result.isLoading ? '로딩중' : result.data.name }으로 쓰면 Cannot read properties of undefined (reading 'name') 이런 에러가 나네요
get 요청으로 받은 데이터를 얻는 방식이 달라진 건가요..?
-
이 게시글은
박순형에 의해 1 년, 1 월 전에 수정됐습니다. 이유: 게시판을 잘못 올렸습니다