Код: Выделить всё
class infintiescroll(BaseModel):
offset: Optional[int] = 0
@app.get("/api/allposts", status_code=status.HTTP_200_OK)
async def allposts(nextpg : infintiescroll):
try:
database = Databases(client).list_documents(database_id= 'xxx', collection_id= 'xxxx',
queries = [Query.select(['thread_content' , 'USER_ID', '$createdAt']), Query.order_desc('$createdAt'),Query.offset(nextpg.offset) ]) #.offset(params.offset)
print(database)
return database
except Exception as e:
raise HTTPException(status_code= status.HTTP_401_UNAUTHORIZED , detail= e) # Return an appropriate error status code
Код: Выделить всё
const fetchdata = async () => {
await axios.get('/api/allposts').then( (res) => setItems(res.data.documents))
.catch((err) => console.log(err));
}
Простой запрос на получение с необязательный параметр.
Подробнее здесь: https://stackoverflow.com/questions/792 ... ble-entity