#sandra_best-practices

1 messages ¡ Page 1 of 1 (latest)

drowsy duneBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1471167973648760985

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

grim crest
#

This was changed in Basil

amber tangle
#

Hi!

#

so is there no way to avoid n + 1 requests? (1 for the invoices list and N per invoice)??

grim crest
#

Why do you need n per invoice?

#

You expand invoice.payments

amber tangle
#

because the payment doesn't have refunded or disputed at the first level

amber tangle
#

we tried this and get an error due to the levels of the expand because we need to list the invoices

#

so when we list them, we expand data.payments.data.payment.charge

grim crest
#

Ah ok

#

Yeah unfortunately it will be multiple calls then

#

Or you can use the older api version

amber tangle
#

Ok, thanks! Another option we thought was using the charges API instead but then we lose the data about attempted payments

grim crest
#

Really I don't recommend calling our api to render a UI at all tbh

#

I recommend listening to webhook events so you can store the data in your database

#

And then every time the page loads, you just query your db

#

This will reduce liklihood of your account getting rate limited

amber tangle
#

Hmmm ok, I'll let know the team, thanks for the suggestion

#

tbh our first option was to use the customer portal but then the users could pay invoices after their subscription is cancelled

#

in any case, thanks for your help!!

grim crest
#

No problem