Skip to content

Commit

Permalink
fix redis code
Browse files Browse the repository at this point in the history
  • Loading branch information
pilcrowonpaper committed Oct 5, 2024
1 parent 5d9a400 commit 1c5b422
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pages/rate-limit/token-bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ export class TokenBucket {
// Ensure that the storage key is unique.
const bucket = new TokenBucket("global_ip", 10, 2);

if (!bucket.consume(ip, 1)) {
const valid = await bucket.consume(ip, 1);
if (!valid) {
throw new Error("Too many requests");
}
```

0 comments on commit 1c5b422

Please sign in to comment.