GuidesAPI Reference
Guides

Cross-Domain JavaScript Requests

Often, browsers prevent access to certain servers due to security restrictions. Cross-Domain JavaScript Requests allow developers to work around security restrictions that would prevent an application from contacting HERE Fuel Prices API directly. For example, certain location information might not be retrievable without enabling this method. In order to allow full access to servers, the HERE Fuel Prices API provides a mechanism to enable client-side cross-origin requests that allow JavaScript resources to be fetched from another domain.

For details on how this mechanism operates, see Cross-Origin Resource Sharing. HERE Fuel Prices API currently uses all headers and parameters of this mechanism.

In order to support browser platforms which don't yet implement Cross-Origin Resource Sharing, GET requests can use JSONP. To use JSONP, your app simply supplies the name of its callback function in the jsoncallback or jsonpCallback query string parameter.

For example, to use JSONP to search Fuel stations with a callback named myCallbackFunction, you could make a request like the following sexample:

GET https://fuel.hereapi.com/v3/stations
?prox=52.516667,13.383333,5000
&jsoncallback=myCallbackFunction
&apiKey=\{YOUR\_API\_KEY\}
📘

Note

The JSONP mechanism only works for GET requests. You can only use POST requests with the Cross-Origin Resource Sharing mechanism previously discussed.