How can I transform an array like this - ["lat","long","abc","def","abcc","deef",] into [lat,long | abc,def | abcc,deef] using javascript?
I am currently encountering an issue with the distance matrix API...
Here is the code snippet I have:
export async function getStoreDistance(locationDetails) {
let destinationRequest = locationDetails.destinations.map(location => {
console.log('destreqlocation', location);
return `${location.lat},${location.long} `;
});
return await axios
.get(
`https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial
&origins=${locationDetails.origins.map(function(locationDetail) {
return locationDetail;
})}
&destinations=${destinationRequest}&key=**********`,
)
.then(function(response) {
// handle success
// return response;
})
.catch(function(error) {
// handle error
return error;
});
}