Streaming live at 10am (PST)

Invoke an API on button click


I am trying to invoke a simple GET api on button click. What is the cleanest way to do that in webflow? I cannot find a way to add custom code or api call in the button settings.

In Webflow, give your button an ID. Then you can make reference to this in your script. Something like this:

const button = document.getElementById('button-id');

button.addEventListener('click', function () {
        .then(function (result) {
        .catch(function (err) {

You can also reference Webflow elements by css classes, element type, data tags or any other regular HTML selector.

1 Like