How to refresh label with new text?

Hello,

I have set up an API call that returns a random quote. Works great!

Now I have a button and a label on a new page. What I want to accomplish is, when the button is clicked, the API is called, and the new quote is set as the text of the label. So, every time user clicks the button → a new quote is shown.

I want to prevent the API get called at loading of the page. So, when users start the page, and ONLY when the user clicks the button THEN the API is called and the quote is shown. Not when the page is loaded. I also want to prevent that I need to refresh the web page to show the new quote on the label.

I’m new to Bubble and trying this as an exercise to understand the basic principles of working with Bubble.

Thank you!! :grinning:

Patrick

Hi!

  1. Create a custom state in your page called “api_text” (text type);

  2. in your text, link it’s value with your page custom state. Just insert the code pagename’s api_text’s value in the text field.

So, every time the custom state changes, your text will change as well.

  1. After click in your button, start a workflow to trigger the call. In the second step, change the custom state value of “api_text” by the received value of the step 1 of your workflow.

Ask if u have any doubt! :call_me_hand:

1 Like

Hey @rpetribu , I am new to bubble and am in a similar situation as @pm12 . Would you be able to show what you meant by your answer in the form of a video (since I could not follow your steps)?

It would be of great help.

Thanks