강의

멘토링

커뮤니티

Inflearn Community Q&A

acumistyle1954's profile image
acumistyle1954

asked

Learn React by Building It: Basics

28 Connecting Cat Data to My App (required to refer to class notes)

https://cataas.com/undefined 로 나오는데 왜그런건가요?

Written on

·

555

1

https://cataas.com/undefined 로 나오는데 왜그런건가요?

28강 수강하고 있는데 fetch를 사용하려고 하는데 이미지가 안나와요 ㅠㅠㅠ

javascriptreact

Answer 4

0

다른 링크로 수정했는데 귀요미들이 잘 나옵니다. 텍스트는 못 넣지만요

      const fetchCat = async (text) => {
        const OPEN_API_DOMAIN = "https://api.thecatapi.com/v1/images/search";
        const response = await fetch(`${OPEN_API_DOMAIN}`);
        const responseJson = await response.json();
        return responseJson[0].url; 
      };

0

jayjinjay님의 프로필 이미지
jayjinjay
Instructor

쏘뇽님 감사합니다. 정확한 답변이에요.

강의 코드와 노트 수정했습니다.

https://github.com/milooy/cat-jjal-maker/blob/main/answers/29-useEffect.html#L48

이 코드 참고해서 fetchCat 함수를 변경해주시면 됩니다.

0

image
강의와 다르게 현재 API 응답값이 바뀌어서 url 이라는 필드가 없습니다.
위의 이미지에 있는 것과 같이 _id 필드를 사용해야 하며

호출해야할 API 주소가 변경되어야 합니다.

 

아래 질문과 같은 문제이니 참고하세요
https://www.inflearn.com/questions/1050883/api%EA%B0%80-%EC%95%88%EB%B6%88%EB%9F%AC%EC%99%80%EC%A7%80%EB%84%A4%EC%9A%94

 

지금 테스트 해보니.. Open API 여서 그런지 서버가 불안정한 것 같습니다ㅠ 됐다 안됐다 하네요ㅜㅜ

0

저도 똑같이 안나오네요 ㅜㅜ

acumistyle1954's profile image
acumistyle1954

asked

Ask a question