You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've built an online store/shopping cart system with Airtable. Generally, I'm a huge lover and evangelist of Airtable.
That said, I just spent the better part of two days trying to figure out why some of my user's Orders were not going through. The culprit: when orders with more than 10 items were created, it was triggeriung a 422 response from a call to base(TABLE_NAME).create(orderItems).
After seeing this function referenced in the Interactive API in my account, I found the source from digging through the code in this repo (this project is severely lacking in documentation – see #93 ) and I didn't see anything that made me think it would error out with more than X records. I was also unable to find any example of how to use a recursive callback of some sort. This function just 422's and doesn't return "remaining" records or anything.
The solution I came up with uses Axios.all() to allow for a true "batch" create using async/await:
constTABLE_NAME='Order Items'asyncbatchCreate(cartItems){letchunkSize=10letchunkedCreateCalls=[]// Split requests into 10 records at a timefor(leti=0,j=cartItems.length;i<j;i+=chunkSize){chunkedCreateCalls.push(base(TABLE_NAME).create(cartItems.slice(i,i+chunkSize)))}try{letnewItems=awaitAxios.all(chunkedCreateCalls)returnnewItems||[]}catch(error){returnError(error)}}
I hope this can help someone else avoid the headache of troubleshooting!
The text was updated successfully, but these errors were encountered:
I've built an online store/shopping cart system with Airtable. Generally, I'm a huge lover and evangelist of Airtable.
That said, I just spent the better part of two days trying to figure out why some of my user's Orders were not going through. The culprit: when orders with more than 10 items were created, it was triggeriung a
422
response from a call tobase(TABLE_NAME).create(orderItems)
.After seeing this function referenced in the Interactive API in my account, I found the source from digging through the code in this repo (this project is severely lacking in documentation – see #93 ) and I didn't see anything that made me think it would error out with more than X records. I was also unable to find any example of how to use a recursive callback of some sort. This function just 422's and doesn't return "remaining" records or anything.
The solution I came up with uses
Axios.all()
to allow for a true "batch" create usingasync/await
:I hope this can help someone else avoid the headache of troubleshooting!
The text was updated successfully, but these errors were encountered: