Webflow sync, pageviews & more.
NEW
Answers

What is the cleanest method in Webflow to invoke a GET API on button click without the ability to add custom code or an API call in the button settings?

If you're unable to add custom code or an API call in the button settings in Webflow, there is still a way to invoke a GET API on button click using a workaround within the Webflow platform. Here's a step-by-step guide on achieving this:

1. Create a Form Element: Start by adding a Form element to your Webflow page. You can find it in the Add Panel (on the left side of the Designer).

2. Customize the Form Element: Modify the Form element to fit your needs. You may need to add a Field element if you want to pass any parameters or data to the API.

3. Configure the Form Settings: Select the Form element, and within the Element settings panel, click on the "Form Settings" gear icon. Make sure to set the "Action" field to the API endpoint you want to invoke (the URL where the GET request needs to be sent).

4. Add a Submit Button: Drag and drop a Button element to the Form element. Customize the button text and style as you desire.

5. Trigger the GET Request: Now, go back to the Form element settings, and under the "Success Action" section, choose "Go to URL." In the URL field, enter the URL of the same page you're currently on (for example, if your page is "example.com/mypage", enter "/mypage" as the URL).

6. Publish or Export: Finally, publish or export your Webflow project to make it live or shareable with others.

What happens next is that when the button is clicked, the form will submit, causing a reload of the current page specified in the "Go to URL" setting. This will simulate a GET API call to the endpoint specified in the form's "Action" setting.

While this workaround does not directly make a GET request without custom code or API settings within the button itself, it achieves the same result by using Webflow's built-in form handling functionality.

Rate this answer

Other Webflow Questions