I have the following code,
await getAuthFailedAttempts().then((attempt) => { errorMessage = VALIDATION_ERROR; if (!attempt.canRetry) { errorMessage = createFailedAttemptsError(attempt); } else { setAuthFailedAttempt(); } this.setState({ loading: false, passcode: "", validationError: errorMessage, });
So how to rewrite to use await properly,
const attempt = await getAuthFailedAttempts();
and how to place the "then" for "attempt"?
thanks in advance
https://stackoverflow.com/questions/66996050/js-await-execution-and-then-placement April 08, 2021 at 09:08AM
没有评论:
发表评论