Query-Solid icon indicating copy to clipboard operation
Query-Solid copied to clipboard

Retrieve a raw list as values without having to use for await

Open jaxoncreed opened this issue 6 years ago • 2 comments

This might already exist, but I didn't see it documented and I was not able to find it while doing a brief amount of code exploration.

Essentially, I'd like to be able to get all values fetched as an array without using for await.... This way I can perform fetches for subsequent values in parallel.

    const friends = [];
    const ldFriends = (await data.user.friends).listValue; // <-- List value does not exist currently. Right now, calling value will return only one of the values retreived
    console.log(ldFriends);
    await Promise.all(ldFriends.map(async ldFriend => {
      console.log(ldFriend.value)
      try {
        friends.push({
          name: (await data[ldFriend.value].vcard_fn).value,
          webId: ldFriend.value
        })
      } catch(err) {}
    }))
    this.setState({ friends });

jaxoncreed avatar May 01 '19 18:05 jaxoncreed

suggestion: .all?

RubenVerborgh avatar May 09 '19 21:05 RubenVerborgh

Yeah. .all sounds good.

jaxoncreed avatar May 10 '19 12:05 jaxoncreed