slowapi
slowapi copied to clipboard
How to call in APIRouter'?
How to call in APIRouter'? Error:AttributeError: 'APIRouter' object has no attribute 'state'
Hi @china-zhoujie can you share your code and the full error message you are seeing? Also please include the versions of Fastapi/starlette that you're using.
It is impossible to help you with what you shared.
Init in the main module, then just reuse in the Router, don't init again
from slowapi import Limiter from slowapi.util import get_remote_address
limiter = Limiter(key_func=get_remote_address)