Rest CallOut can be made in Salesforce in two ways:
- Server-side controller (Apex Class)
- Client-side controller (Js Controller)
- Server-side controller (Apex Class): We can make an API callout from Apex , which provides support for REST and SOAP callouts. Before making callouts from the apex, we have to add our endpoint in “Remote Site Setting”.
To add endpoints in CSP, search for CSP in the quick find box and click “CSP Trusted Sites.”
In this callout, whenever we hit the API, I call the random joke API, which returns a new joke every time.