React Native给出错误:TypeError:undefined不是对象(正在评估'item.enclosures [0] .url')

I have been having this problem, that I think is related to slow fetching. I fetch from itunes API to get podcasts for this app I build. on some podcasts it manages to work, but on others it shows that message, Here is the error: [error image] [1]: https://i.stack.imgur.com/tMmhP.png Here is my code:

EpisodesView.tsx:

    import React, { useState, useEffect } from 'react';
import { ScrollView, Text } from 'react-native';
import { observer } from "mobx-react";
//components
import Episode from './Episode';
import { useRootStore } from '../contexts/RootStoreContext';
import BottomGap from './BottomGap';
import PodcastTitle from './PodcastTitle';
import PodcastImage from './PodcastImage';
import SubscribeIcon from './SubscribeIcon';
import { fetchPodcast } from '../Api/Fetches';

//shows all of the episodes of a certain podcast
const EpisodesView = ({ route, navigation }) =>{ 
     //a constant to tell the <Episode /> what page he is on
     const fromMyListScreen = false;  
    // const { cachingStore } = useRootStore();

    const [podcast, setPodcast] = useState({
        title:'',
        image: undefined,
        description: '',
    })
    const [rss, setRss ] = useState();

    useEffect(() => {
        //fetch podcast
        fetchPodcast(route.params.rssUrl)
            .then((rss) => {
                setRss(rss);
            })
            .catch((err)=>{
                console.log(err)
            })
    })

    //show all episodes of the podcast
    const showEpisodes = () => {
        return rss.items.map(item => {
            var track = {
                id: item.id,
                url: item.enclosures[0].url,
                title: item.title,
                artwork: item.itunes.image ,
                artist: rss.title,
                description: item.description,
                duration: item.itunes.duration,
                rssUrl: route.params.rssUrl,
            }
            return (
                <Episode track={track} key={track.id} fromMyListScreen={fromMyListScreen} />
            );
        })

    }
    var showTitle = rss?(
        <PodcastTitle title= {rss.title}/>
    ):(
        undefined
    )

    var showImage = rss? (
        <PodcastImage image={rss.itunes.image}/>
    ):(
        undefined
    )

    return (      
        <ScrollView>      
          {showTitle}
           {showImage}
           <SubscribeIcon />
            <Text style={{ paddingTop:20,paddingBottom:20}}>{podcast.description}</Text>           
            {rss? showEpisodes(): undefined}
           <BottomGap />
        </ScrollView >
    )
};

export default observer(EpisodesView);

我提取的文件: Fetches.ts:

//fetches a specific podcast
export const fetchPodcast = (url) =>{   
    return fetch(url)
    .then((response) => {
        return response.text()
    })
    .then((data) => {
         return rssParser.parse(data)
     })
    .then((rss) => {
        return rss;
    })
     .catch(err => {
        console.log(err);
    });
};

我必须说它确实存在,并且不是未定义的,请使用console.log + postman检查 顺便说一句, 这样做时:

var track = {
                id: item.id,
                //url: item.enclosures[0].url,
                title: item.title,
                artwork: item.itunes.image ,
                artist: rss.title,
                description: item.description,
                duration: item.itunes.duration,
                rssUrl: route.params.rssUrl,
            }

它带来了另一个问题,另一个函数可以延长持续时间, 所以我认为它只是无法在渲染之前全部获取 (顺便说一下,这是播客的“语法”)

你有解决方案吗? 谢谢