slowapi icon indicating copy to clipboard operation
slowapi copied to clipboard

How to call in APIRouter'?

Open china-zhoujie opened this issue 3 years ago • 5 comments

How to call in APIRouter'? Error:AttributeError: 'APIRouter' object has no attribute 'state'

china-zhoujie avatar Nov 03 '22 03:11 china-zhoujie

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.

laurentS avatar Nov 08 '22 13:11 laurentS

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)

marrocksd avatar Nov 24 '22 15:11 marrocksd