return array of objects in shape of string [object Object]
hosseindindar1 opened this issue · 1 comments
hosseindindar1 commented
when I want to perform an array of objects and return that
when I check in console I get objects that converted to string
developit commented
Not much to do with Arrays really - you're just not waiting for your promises to resolve:
export async function foo() {
const things = [1,2,3].map(thing => fetch(thing).then(r=>r.json()));
// ^ these are promises, they can't be serialized
const resolved = await Promise.all(things);
// ^ now they are values and will be serialized normally
return resolved;
}