You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into a problem when I tried to use the rate limit api, this is my code:
use worker::{event,Context,Env,RateLimiter,Request,Response,Result};#[event(fetch)]asyncfnfetch(_req:Request,env:Env,_ctx:Context) -> Result<Response>{
console_error_panic_hook::set_once();let api_rate_limit = env.get_binding::<RateLimiter>("API_RATE_LIMIT")?;let res = api_rate_limit.limit("111".to_string()).await?;if res.success{returnResponse::ok("Hello World!");}Response::error("too many request",429)}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I ran into a problem when I tried to use the rate limit api, this is my code:
and wrangler.toml:
When I run the code and prepare to try to access, I get the error:
[wrangler:inf] GET / 500 Internal Server Error (2ms) ✘ [ERROR] Binding cannot be cast to the type RateLimiter from Ratelimit
Is the way I'm using the API incorrect? How to use rate limit api? please help…
Beta Was this translation helpful? Give feedback.
All reactions