Module import of .sorted object from async-await functions return empty array [object] properties

Viewed 13

When generating a filtered and sorted list, my initial document returns a perfectly populated array of objects and properties.

However, if I import that into another document to run further operations, the array returns empty properties, despite using async/await and Promise.all to fulfill all promises from the previous exported function.

Here is my exported function from the filter and sort:

export async function V2V2SORT() {
  try {
    const dexdata = await COMPAREV2V2();
    const dexdatafilter = dexdata.filter((item): item is any => (item !== undefined && item.v2a.reserve0 > 10 && item.v2b.reserve1 > 10));
    const dexdatasorted = dexdatafilter.sort((a, b) => {
      return b.diffPercent - a.diffPercent;
    })
    console.log(dexdatasorted)//DEBUG
    return Promise.all(dexdatasorted);
  } catch (error) {
    console.log(error);
  };
}
V2V2SORT()

And here is my imported function, which only attempts to aggregate 3 similar arrays into one:

import { V3V2SORT } from './dexdata/V3V2SORT/V3V2SORT';
import { V2V2SORT } from './dexdata/V3V2SORT/V3V2SORT';
import { V2V3SORT } from './dexdata/V3V2SORT/V3V2SORT';


export async function dexSort() {
    let v3v2 = await V3V2SORT();
    let v2v2 = await V2V2SORT();
    let v2v3 = await V2V3SORT();
    const alldex = [] as any;
    alldex.push(v3v2);
    alldex.push(v2v2);
    alldex.push(v2v3);
    console.log(alldex);
    return alldex;
}
dexSort()

My import data appears like this:

  [
    {
      pair: [Object],
      v3: [Object],
      v2: [Object],
      diffPercent: 460.92231367298285,
      direction: [Object]
    },
    {
      pair: [Object],
      v3: [Object],
      v2: [Object],
      diffPercent: 0.22076681012417426,
      direction: [Object]
    }
  ]

I assume there is a clue in the fact that the diffPercent properties carry through properly, while all other data is scrubbed.

If I log results to console from within V2V2SORT() using console.log(dexdatasorted) I get expected results. When I import them and attempt to put them into a single array in DEXSORT(), I receive an empty array; except for the diffPercent property which reads fine.

0 Answers
Related