dcts/opensea-scraper

All Functions return Promise { <pending> }

SKreutz opened this issue · 1 comments

Hey,

if I try to use any function it returns "Promise pending".

I also removed the "await" from the functions because I get this error if i keep it:

const ranking = await OpenseaScraper.rankings(nbrOfPages, options);
                ^^^^^

SyntaxError: await is only valid in async functions and the top level bodies of modules

I would appreciate your help :)

Code used:

const OpenseaScraper = require("opensea-scraper");

// options
const options = {
  debug: false,
  logs: false,
  sort: true,
  browserInstance: undefined,
}

const nbrOfPages = 1;
const ranking =  OpenseaScraper.rankings(nbrOfPages, options);
console.dir(ranking)
dcts commented

@SKreutz you can either use .then or wrap it around an annonymous async function:

// use .then syntax
OpenseaScraper.rankings(nbrOfPages, options).then(ranking => {
  console.dir(ranking)
});
// wrap around self evoking annonymous async function
(async () => {
  const ranking = OpenseaScraper.rankings(nbrOfPages, options);
  console.dir(ranking)
})();