Created
August 9, 2017 03:12
-
-
Save JitendraZaa/82983e4e47d1ff5e97b7976527d6be9f to your computer and use it in GitHub Desktop.
For Blog post - http://www.jitendrazaa.com/blog/salesforce/lightning-component-for-wikipedia-search/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Author : Jitendra Zaa | |
| * Desc : This Controller is used by Lightning component to make Http request to Wikipedia | |
| * */ | |
| public class WikiHttpRequest { | |
| @AuraEnabled | |
| public static String getWikiResponse(String searchText, Integer searchLimit){ | |
| HttpRequest req = new HttpRequest(); | |
| req.setEndpoint( 'https://en.wikipedia.org/w/api.php?action=opensearch&search=' + searchText + '&limit='+ | |
| searchLimit + '&namespace=0&format=json' ); | |
| req.setMethod('GET'); | |
| Http http = new Http(); | |
| HTTPResponse res = http.send(req); | |
| return res.getBody(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment