Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

undefined is not an object (evaluating 'item.Attraction.Name')

$
0
0

I have the following request in Get:

app.get('/attraction/:routeid', async(req,res)=>{    let response = await attraction_routes.findAll({        attributes: ['attractionId'],        where:{routeid: req.params.routeid},        raw: true,        include: [{            model: Attraction,            required: true,            attributes: ['Name','Desc','Address']        }],        order: [['id', 'ASC']]    });    res.json(response)});

And it returns the following JSON:

[   {"attractionId":1,"Attraction.Name":"Mirante Cerro Santa Lucia",   },   {"attractionId":2,"Attraction.Name":"Cajon del Maipo",   }]

I want to access the Attraction.Name attribute in the rendering of my item on my page, but when I define it in my variable there is an error *undefined is not an object (evaluating 'item.Attraction.Name') *

function renderPost(item){return(<View style={styles.card}><Text style={styles.title}>      {item.Attraction.Name}</Text></View>)};

Error Image


Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>