Forum Discussion

EquatorDevelopr's avatar
11 years ago

Call Endpoint from Custom Component

Hi,   I want to get results from an endpoint in my component without using JS, is there any way to achieve this?   In endpoint I use http.client to query external web API and I want to be able to...
  • VarunGrazitti's avatar
    11 years ago

    EquatorDevelopr - I don't think there is any other way of doing this, you can call an endpoint via ajax call from your custom component. About endpoints

     

    You can use the following code:

     

    <#assign your_endpoint_url = "/plugins/custom/community_name/community_name/your_endpoint" />
    
    <@liaAddScript>
    (function($) {
            $(document).ready(function() {
    			$.get( "${your_endpoint_url}" ).done(function( data ) {
    						//your code goes here
                        }).fail(function() {
    						//something
    					})     
    		});
    })(LITHIUM.jQuery);
    </@liaAddScript>

     

    Other threads