You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the api in a ladda-wrapped call returns an array, only the initial call (that does the actual request) returns the array as expected. Any subsequent call (that's fetching the entity from the cache) will return the array parsed an object instead.
It's surprising that the type changes "on the fly" and ladda should probably return the entities more consistently (ideally the way they came from the backend).
A workaround is to wrap the ladda call in another function that extracts the values from the response if it's an object:
exportconstgetEntitiesAsArray=async(id: string)=>{constentities=awaitapi.myEntities.getAllForId(id);// Because ladda parses arrays as objects when returning from cache, we need to retransform to an array here.returntypeofentities==='object' ? Object.values(entities) : entities;};
The text was updated successfully, but these errors were encountered:
If the api in a ladda-wrapped call returns an array, only the initial call (that does the actual request) returns the array as expected. Any subsequent call (that's fetching the entity from the cache) will return the array parsed an object instead.
It's surprising that the type changes "on the fly" and ladda should probably return the entities more consistently (ideally the way they came from the backend).
Example
Initial ladda call returns:
Second and subsequent ladda calls return:
Current workaround
A workaround is to wrap the ladda call in another function that extracts the values from the response if it's an object:
The text was updated successfully, but these errors were encountered: