Forma Developer Forum
Welcome to Autodesk Forma Developer Forum. Share your knowledge, ask questions, and explore popular Forma API topics.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to get the each object data in the storage.listObjects() ?

Message 1 of 6
172 Views, 5 Replies

Is there a way to get the each object data in the storage.listObjects() ?

I currently use the listObjects() method with a prefix to get a list of objects that I previously saved. This method will return an array with the key of the object along some metadata. So, if my list has 10 objects I have to subsequently make 10 calls to the storage.getTextObject() with the keys to get a list of my objects. 

Is there a way so I just make the one to get all the objects along with their data based on a prefix??

Or alternatively is there some other approach you can recommend?  

Thank you

Tags (2)
Labels (1)
Message 2 of 6
in reply to: iklimis



You are right in that you have to do one call per object you want to get. However, these calls can be run in parallel using e.g. Promise.all([promise1, promise2,..]). Hope this answers your question.



Message 3 of 6
in reply to: iklimis

@vilde.barth Thanks for your reply!

Yes I imagined as much - in that I will have to chain a number of Promises - but isn't  somewhat risky say if I have to make 10 calls subsequently ? 
What if one or more fail? Either I have to catch the whole error and make the user retry or I have to keep track of the failed ones and again restart the chain for the failed Promises.

that might nor be optimal for UX


Message 4 of 6
in reply to: iklimis

@iklimis I see your concern, but I do not believe this is something we will support. Can you explain your use case for needing to make 10 calls so we can better understand your concern? 🙂 


Also, if you want to keep track of the each of the promises, you can use Promise.allSettled(..). 


Message 5 of 6
in reply to: iklimis

@vilde.barth Hi!
Yes let me try to explain the use case: I would like to keep an item list of sorts. Each list item has its own metadata. Think of it as a Todo app. 

In my welcome page I would like to show all todos which some todo info. I would like to take all todos from the storage with one call instead of keeping a list of todo-ids and getting each todo info by making a seperate storage call for each todo.
I would like to avoid say in a case of 20 Todos to make 20 storage calls for each individual Todo info.

Message 6 of 6
in reply to: iklimis

@iklimis Thanks for explaining! I understand your use case, but I do not believe we will add support for getting multiple objects at the same time. If I understand correctly and you want to access all of the items at the same time, is it an alternative for you to store all the data in one object?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report