reactnative save data asyncstorage

Viewed 23

Guys I call the getdatas into useEffect but still it's not saving and give this error, [TypeError: getCountry is not a function. (In 'getCountry(ulke)', 'getCountry' is "2")]

Im just started the reactnative, please explain easily thanks.

(Im selecting datas into picker btw)

const fetchPray = async county => {
    const url4 = '' + county;
    console.log(url4);
    fetch(url4)
        .then(response => response.json())
        .then(pray => {
            setPray(pray);
            let index = pray.findIndex(d => d.MiladiTarihKisa === date);
            let selectData = pray[index];
            setVakitGunes(selectData.Gunes);
            setVakitImsak(selectData.Imsak);
            setVakitOgle(selectData.Ogle);
            setVakitIkindi(selectData.Ikindi);
            setVakitAksam(selectData.Aksam);
            setVakitYatsi(selectData.Yatsi);
            setGunTurkce(selectData.MiladiTarihUzun);


            AsyncStorage.setItem('ulke', getCountry);
            AsyncStorage.setItem('il', getCity);
            AsyncStorage.setItem('ilce', getCounty);
            AsyncStorage.setItem('gunes', vakitGunes);
            AsyncStorage.setItem('imsak', vakitImsak);
            AsyncStorage.setItem('ogle', vakitOgle);
            AsyncStorage.setItem('ikindi', vakitIkindi);
            AsyncStorage.setItem('aksam', vakitAksam);
            AsyncStorage.setItem('yatsi', vakitYatsi);
            AsyncStorage.setItem('tarih', gunTurkce);
        }).catch(error => console.log(error))
        .finally(() => setLoading4(false));
};

const getDatas = async () => {
    try {
        const ulke = AsyncStorage.getItem('ulke');
        getCountry(ulke);
        const ilce = AsyncStorage.getItem('ilce');
        getCounty(ilce);

        const il = AsyncStorage.getItem('il');
        getCity(il);

        const gunes = AsyncStorage.getItem('gunes');
        setVakitGunes(gunes);

        const imsak = AsyncStorage.getItem('imsak');
        setVakitImsak(imsak);

        const ogle = AsyncStorage.getItem('ogle');
        setVakitOgle(ogle);

        const ikindi = AsyncStorage.getItem('ikindi');
        setVakitIkindi(ikindi);

        const aksam = AsyncStorage.getItem('aksam');
        setVakitAksam(aksam);

        const yatsi = AsyncStorage.getItem('yatsi');
        setVakitYatsi(yatsi);

        const tarih = AsyncStorage.getItem('tarih');
        setGunTurkce(tarih);
    } catch (error) {
        console.log(error);
    }
};
0 Answers
Related