I am working on an Ionic (v1) app, I am doing a simple call to this endpoint:
Which works correctly if you simply open it on a browser, it returns well formed JSON (I can copy it and parse it on a jsonviewer).
But if I call it using $http's jsonp method (I use jsonp because otherwise it will cause a CORS error), it will cause this error:
Uncaught SyntaxError: Unexpected token :
This is my code (simplified):
$http.jsonp('https://maps.googleapis.com/maps/api/directions/json?origin=25.6909532,-100.3705846&destination=25.6909532,-100.3705846&waypoints=optimize:true|25.6507548,-100.3424051|25.6546534,-100.356101|25.63622,-100.3124573', {jsonpCallbackParam: 'callback'})
.then(function(response){
console.log(response);
});
Also I see that the browser is getting the json response correctly: