J
J
jeruthadam2020-01-15 19:43:28
JavaScript
jeruthadam, 2020-01-15 19:43:28

Replacing request: why doesn't it work in a loop?

Due to the untimely death of the module request, I decided, as a real hipster, to find a fashionable replacement. Everyone recommends a module gotfrom one of the top mods in the Javascript world. Decided to try it and immediately ran into a problem.

while (currentPage <= lastPage) {
  const response = await got(`http://example.com/?page=${currentPage}`);
  currentPage++
}

In the above code, this one gotsends a request constantly only to 1 page (i.e. the first iteration. I tried to replace all the same, just instead of it the good old one request- everything works without problems. But this bastard does not work. What is it and how?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question