Here is the uber api documentation:
curl -H 'Authorization: Token <SERVER_TOKEN>' \
-H 'Accept-Language: en_US' \
-H 'Content-Type: application/json' \
'https://api.uber.com/v1.2/estimates/price?start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-122.518075'
Here is the code I am using:
jQuery.ajax({
type: "GET",
url: "https://api.uber.com/v1.2/estimates/price?start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-122.518075",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Token <myToken>");
xhr.setRequestHeader('Accept-Language', 'en_US');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader("Access-Control-Allow-Origin","*");
},
success: function(data){
console.log(data);
}
});
The error I am receiving is "Access to XMLHttpRequest at 'https://api.uber.com/v1.2/estimates/price?start_latitude=37.7752315&start_longitude=-122.418075&end_latitude=37.7752415&end_longitude=-122.518075' from origin 'null' has been blocked by CORS policy: Request header field access-control-allow-origin is not allowed by Access-Control-Allow-Headers in preflight response."
I figured that would have been handled in my headers, but I have gone awry somewhere.
Thanks in advance!
EDIT: CORRECT RESPONSE BELOW