I
I
ince2020-06-15 22:51:08
JavaScript
ince, 2020-06-15 22:51:08

How to perform the action many more times after an error?

async text => {
  let err = false
  do {
    try {
      let result = await request(text)
      err = false
    } catch (e) {
      err = e
    }

  } while (err);

}


I send requests and get a result or an error.
When I get an error - I want to send requests so many more times until I get a result.
Wrote such function when I receive an error - execution stops.
What have I done wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
casoer, 2020-06-21
@casoer

const c = async a => { try{ await request() } catch(e) {c()} }

It's possible, but I don't recommend it. There may be an overflow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question