repeat over 2 data sources

  • mossi9682-1295184293869391995

    mossi

    5 months ago

    I have a div that is repeated over an array from an api call. (user creation api). The div shows some user info and repeats it for users created. Once user is created they can create items. I have another api that gets the number of items each user created (gets this from db, based on user ID). In the repeated div I want to also show total number of items created for each user in their own repeated div. How do I do this?
  • lucasg-1295194969912377345

    Lucas G

    5 months ago

    You should be able to do this with the Size node
  • If you're filtering an array based on user Id, you can pass that array into the node and get a number
  • mossi9682-1295205138717343746

    mossi

    5 months ago

    I figured out that part of it. My issue is that once the div is repated over the first api call, how do it dynamically pass values to the same div from other api calls. i.e. the api call that the repeat is based on outputs an array like user1, user2. And another api call returns another array like user1 total items(= 3 after using Size fx), user2 total items (= 1). Now i want 3 and 1 to be in the repeated div that belongs to user 1 and user 2 respectivly.
  • tomthebigtree-1295254029735301242

    Tom Ireland

    5 months ago

    Do you receive any kind of user identifier in the second API call? You could use that as a comparison to populate your other element with the total e.g. Get total items where repeat item userid == API call userid. Hard to advise without seeing the setup or understanding the flow from beginning to end.
  • mossi9682-1295301205492367400

    mossi

    5 months ago

    Hi Tom,
    Yes I have userid reference to the same user in both api calls. how do implement the approach you recommanded? do i make a formula?
  • tomthebigtree-1295306021086036009

    Tom Ireland

    5 months ago

    I'm at work now but can take a look later on. Can you show an example screenshot of the formula you're using for the repeat div and the second API call where you're already setting size to get the total number of items?
  • mossi9682-1295315149871382631

    mossi

    5 months ago

    here you go. Plz note in this example, the total items belongs to the user of index 1 (not index 0). The repeate div api call returns all the users in db and userids are returned as we. The second api call returns total items created for a user with a given userid. Same userid reference for any given user is included in both api calls.
    1295315149393104947-
    1295315149988565014-
  • Tod-1295315154602295357

    Tod

    5 months ago

    Great energy @mossi! Your continuous contribution to the toddle Community just made you advance to Community Level 2!
  • magical_fawn_52793-1295335806193500221

    Kai

    5 months ago

    hey, just copy the data of api to a variable as an array of the data sent by the api. Then call the second api an add the result to the array. With this you can show them both in same repeat... Hope I understood you correctly...
  • lucasg-1295405944603148359

    Lucas G

    5 months ago

    You just use the repeated item's Id to filter the array and use size
  • It doesn't change anything and it's fine if it is two different calls that you're using
  • As long as the Id of the repeated item matches
  • mossi9682-1295468468921045002

    mossi

    5 months ago

    the userids inside data of each index matches but the indexes dont match. For example in the screenshots i provided the 4 indexes of returned data in the screenshot on the right belong to index 1 of the screecshot on the left (which is the array the repeat is based on). here is my div structure; the parent div is repeated over the api with 2 indexes and I want the h3 value to bind with the output of api call with 4 indexes for a given userid dynamically. in this example the value 4 belongs to index 1 of the repeat array.
    1295468468727975956-
  • lucasg-1295469821789732987

    Lucas G

    5 months ago

    Yeah exactly just filter the second one with the userid
  • Index doesn't matter

Stop scrolling. Start building.

toddle is a visual web app builder that rivals custom code — but accessible to your entire team!

Try toddle — it's free!

© Copyright 2024 toddle. All rights reserved.