강의

멘토링

로드맵

Inflearn Community Q&A

ezh291461's profile image
ezh291461

asked

Delivery App Clone Coding [with React Native]

Troubleshooting react-native-config

const errorResponse: AxiosResponse<unknown, any> 개체가 '알 수 없는' 형식입니다

Written on

·

2.5K

0

try {
      setLoading(true);
      const response = await axios.post(`${Config.API_URL}/user`, {
        email,
        name,
        password,
      });
      Alert.alert('알림', '회원가입 되었습니다.');
      navigation.navigate('SignIn');

    } catch (error) {
      const errorResponse = (error as AxiosError).response;
      console.error(errorResponse);
      if (errorResponse) {
        Alert.alert('알림', errorResponse.data.message);
      }
    } finally {
      setLoading(false);
    }

 

 

 

if안에서  errorResponse  타입을 지정하라고 에러가 계속 납니다

강의에서는 안나는 부분인데 어떻게 해야 하나요?

 

react-native

Answer 1

2

zerocho님의 프로필 이미지
zerocho
Instructor

(errorResponse.data as any).message 하시면 됩니다.

any는 추후 정확한 data의 타입으로 수정하시면 되고요.

Gray Sheep님의 프로필 이미지
Gray Sheep
Questioner

빠른답변 감사합니다!!

ezh291461's profile image
ezh291461

asked

Ask a question