
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: https://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.
Comments
Join the discussionNo comments yet. Be the first to comment.
Bubble Plugin
I have included all the information related to how you can build the Bubble plugin in this series. Check my course on how to build plugin from scratch- https://nocodetalks.co/bubbleplugin



