function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Dali Kilani 4Dali Kilani 4 

use ajax to access external resources from a lightning controller?

Hi,

I would like to hit an extenal REST API and fetch some data using Ajax in th controller bound to my aura:component. Is this possible? I can't seem to find any reference to this.

Thanks
KK Ramamoorthy:-)KK Ramamoorthy:-)
You will have to use the Server side Apex Controller for this as client side AJAX calls for external resources are not supported due to CSP. Please refer to this link on how to use APEX callouts for REST services https://developer.salesforce.com/page/Apex_Callouts

To know more about apex controller in lightning, see page 145 of the document below 
http://www.salesforce.com/us/developer/docs/lightning/lightning.pdf