Help forum

Issue preselecting data

  • Iconic

    8 months ago

    I have a few functions I'm running that supposed to preselect an item in an array on page load and api request success but they don't work. I've tried multiple methods all to no avail, whats the best way to approach this
  • Erik Beuschau

    8 months ago

    It depends a bit on your setup, but here's what I would normally do:
    - Make sure your API request is fetched during SSR
    - Add a formula called Selected item that will default to the first item from your API response for instance
    - Use a query parameter to control if another item should be selected and use that query parameter in the formula above
    - Avoid using on load + API on success if possible and prefer the formula instead since it's reactive by default