Pricing Blog

How do you organize your variables?

  • luca_6412-1403396343904473149

    Luca_

    4 months ago

    When you have a main object that includes related “addon” data, how do you structure and manage it on the frontend without ending up with a messy implementation?

    Example: You fetch a Product object from your API, which already includes its Category as an addon. In your form, you need to edit the product’s details and also choose a category from a separate list you’ve fetched via another API call.

    How do you handle the incoming object with its addons and track the user’s edits?

    When submitting changes, do you send only the modified fields (PATCH) or the entire object ?

    What is considered the most flexible best practice for this scenario?
  • lucasg-1403399604187299850

    Lucas G

    4 months ago

    If data is heavily nested to where it makes it hard to track and make changes then you might want to see if you can restructure how you store that data first
    👍1
  • lucasg-1403399922677452880

    Lucas G

    4 months ago

    If you have a lot of variables then you can refactor things out into components to have them handle specific things
  • As for the calls, I would only patch what needs to be updated only