PricingBlog

Issue preselecting data

  • iconic4213-1477305263374729368

    Iconic

    1 month 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
  • erikbeus-1477980223885541459

    Erik Beuschau

    1 month 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