-2
Last week I followed Next Level Week, which brought the idea of creating a system for Mobile and Web, the web part I was able to do, all according to the video. but I have a problem so far in the Mobile part exactly in the 4 video that should returns me the collection points already registered. but the error that returns is this [Unhandled promise rejection: TypeError: undefined is not a function (near '...points.map...')]
according to video, everything is the same, but even so returns me this error.
Below goes the code with everything related to the collection point
interface Point {
id: number;
name: string;
image: string;
latitude: number;
longitude: number;
}
const [points, setPoints] = useState<Point[]>([])
useEffect(() => {
api.get('points', {
params: {
city: 'Mossoró',
uf: 'RN',
items: [3, 5, 6]
}
}).then(response => {
setPoints(response.data)
console.log(response.data)
})
}, [])
{points.map((point) => (
<Marker
key={point.id}
style={styles.mapMarker}
onPress={handleNavigateToDetail}
coordinate={{
latitude: point.latitude,
longitude: point.longitude,
}}
>
<View style={styles.mapMarkerContainer}>
<Image
style={styles.mapMarkerImage}
source={{
uri: point.image,
}}
/>
<Text style={styles.mapMarkerTitle}>{point.name}</Text>
</View>
</Marker>
))}
when Voce da um
console.log()
in thepoints
, what appears?– Cmte Cardeal