Call API inside the element in Bubble Plugin

Call API inside the element in Bubble Plugin

Play this article

There are times when you need to call the API within the element section instead of the API section, but how do you do it?

Let me demonstrate with an example.

I will call this GET API: dummy.restapiexample.com/api/v1/employees

We will be using jQuery for this purpose.

 $.getJSON('https://dummy.restapiexample.com/api/v1/employees')
    .done(function(json_data) {
         //success 
        console.log("data is " , json_data);
    })
    .fail(function(jqXHR, textStatus, errorThrown) {
        //come here if there is any error while calling the api
        console.error("Error: " + textStatus + ", " + errorThrown);
    });

POST API Example-

$.post('https://dummy.restapiexample.com/create', {name:'test',salary:'123',age:'23'}    )
  .done(function(response) {
    console.log('Success:', response);
  })
  .fail(function(jqXHR, textStatus, errorThrown) {
    console.error('Error:', textStatus, errorThrown);
  });

That's all for this blog. Subscribe for more future updates. Thank you!

Follow me on Twitter.

Checkout My Bubble Plugin Course - Use coupon code "THEBUBBLEGROUP" at checkout for 10% discount.