CMS Development

prasadcolumbus
Participant | Diamond Partner
Participant | Diamond Partner

How to call outside API's on Hubl language

How to call outside API's(http://ip-api.com/json/182.72.242.178) on Hubl language 

I wrote the code below.But it's not working

{% set ipadress="~ curl http://ip-api.com/json/182.72.242.178" %}

0 Upvotes
3 Replies 3
TRooInbound
Key Advisor

How to call outside API's on Hubl language

Hi @prasadcolumbus 

you can write Ajax code with JavaScript code, like this

 

<script>
  $(document).ready(function() {
     function ipLookUp() {
    $.ajax('https://ipapi.co/json/')
        .then(
            function success(response) {
                var country = response.country_name.split(' ').join('_').toLowerCase();
                alert(country)
              //if you need class in body
                $('body').addClass(country);
            },

            function fail(data, status) {
                console.log('Request failed.  Returned status of',
                    status);
               
            }
        );
}
ipLookUp();
  });
</script>

Demo - http://bit.ly/30cgOqt

------------------------------------------------------------------

Did our post help answer your query? Help the Community by marking it as a solution.

Team TRooInbound

 

For more information please visit our website or mail us at hello@trooinbound.com

prasadcolumbus
Participant | Diamond Partner
Participant | Diamond Partner

How to call outside API's on Hubl language

Without jQuery is their any possiblity way to call API threw Hubl language?

 

I am having some issues on using jQuery to load the content

EdNoble
Participant

How to call outside API's on Hubl language

touch. (this needs to be answered)

0 Upvotes