Error when create react native maps

Hello. I’m startting build a react-native maps with expo. but when i get directions bettween two points by polyline, i got this error:
TypeError: undefined is not an object (evaluating ‘respJson.routes[0].overview_polyline’)
Here is my code:
let resp = await fetch(${ startLoc }&destination=${ destinationLoc }&key=$(key));
let respJson = await resp.json();
let points = Polyline.decode(respJson.routes[0].overview_polyline.points);
let coords = => {
return {
latitude: point[0],
longitude: point[1]
this.setState({coords: coords})
return coords;
Thank you everyone;


It would be a bit easier to see what your code is doing if you make it into a code block :slight_smile:


What does respJson look like? e.g.:

  let respJson = await resp.json();
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.