i want to get the nested response in FAST API after creating,
def createOrderPlace(request: OrderCreatePlaceOrder, db: Session):
x = format(random.randint(10000,99999), '04d')
exists_x=db.query(OrderModel).filter(OrderModel.order_id == x).first()
if exists_x:
x = format(random.randint(10000,99999), '04d')
order_create = OrderModel(
user_id=request.currentUser.user_id,
name=request.currentUser.name,
email=request.currentUser.email,
orderAmount=request.subtotal,
cvv_id=request.currentUser.cvv_id,
name_on_card=request.currentUser.card_name,
card_numbr=request.currentUser.card_number,
card_month=request.currentUser.card_month,
card_year=request.currentUser.card_year,
order_id=x,
)
db_orderid = (
db.query(OrderModel)
.filter(OrderModel.user_id == request.currentUser.user_id)
.first()
)
for dic in request.cartItems:
order_item_a = OrderItemsModel(
name=dic.item_name,
quantity=dic.item_quantity,
price=dic.item_price,
decscription=dic.item_decscription,
product_type=dic.item_product_type,
)
db.add(order_item_a)
db.add(shipping_a)
db.add(order_create)
db.commit()
return request
here is my response after creating
{
"currentUser": {
"user_id": 0,
"name": "string",
"email": "string",
"product_is_active": true,
"billing_first_name": "string",
"billing_last_name": "string",
"billing_phone_number": "string",
"billing_country": "string",
"billing_division": "string",
"billing_district": "string",
"billing_address": "string",
"billing_police_station": "string",
"billing_post_code": 0,
"shipping_first_name": "string",
"shipping_last_name": "string",
"shipping_phone_number": "string",
"shipping_country": "string",
"shipping_division": "string",
"shipping_district": "string",
"shipping_address": "string",
"shipping_police_station": "string",
"shipping_post_code": 0,
"cvv_id": 0,
"card_name": "string",
"card_number": "string",
"card_month": 0,
"card_year": 0
},
"cartItems": [
{
"item_id": 0,
"item_name": "string",
"item_price": 0,
"item_description": "string",
"user_id": 0
}
],
"subtotal": 0
}
but I don't know how to get the exact same response in get method,in fastapi serach for how to get the nested response, but the problem is i need the exact response in get method. help me to get the same response in get method