I have a working function that looks like this:
const handleClickOnFavouriteLocation = (item: any) => { console.log('MY COORD', item.coordinates); if(data){ console.log('DATA COORD', data.personalFavouritePlaces.nodes[0].center.coordinates); } const addressDetails = { coordinates: item.coordinates, }; chooseLocation(addressDetails); };
Currently, the item here is hard-coded and it works. However, I am trying to replace the hardcoded item with items returned via grapqhl. However, I get an error in the coordinates field because of a difference in shapes.
For example, If I check item.coordinates
on the log, I see this. The length is 2:
MY COORD (2) [8.217462, 53.13975](2) [8.217462, 53.13975]0: 8.2174621: 53.13975length: 2__proto__: Array(0)
However, when I check an example of the coordinates returned from graphql, I see this:
DATA COORD [Array(2)]DATA COORD [Array(2)]0: (2) [8.183364, 53.157753]length: 1__proto__: Array(0)
The length here is 1. Even though both of them seem to be the same thing. How can I change the grahql returned data (coordinates field) such that it can be used exactly like the hard-coded one?