Closed duc-anh-tran closed 3 years ago
Just wrap the entire thing with promise:
return new Promise((resolve, reject) => {
limiter.removeTokens(1, (err: Error, remaining: number) => {
if (err) reject(err);
if (remaining < 0) {
reject(new RateLimitError("Too many requests"));
} else {
fetcher().then(resolve);
}
});
});
I used
await
insidecallMyRequestSendingFunction(...)
. Is it possible to use async function as callback? As I tried adding async,