I have working with [email protected] package, I have many data to be exported to Google Sheet,
for now I use this code
const insertDataToSheet = async (data, sheet, msg) => {
let query = []
try {
data.map(async item => {
query.push(promisify(sheet.addRow)(item))
})
const result = await Promise.all(query)
if (result) return result
throw new Error(`${msg} Unkown Error`)
} catch (e) {
throw new Error(`${msg} Failed: ${e.message}`)
}
}
This code is working with 100 data or less, but if I use 150+ data the connection not support it.
Error List
- Client network socket disconnected before secure TLS connection was established
- Socket hang up
- Error: HTTP error 429 (Too Many Requests)
Is there any limitation for
Promise.all
.?
or
Is there any better solution to export batch / bulk data to Google Spreadsheet?
In final i work on this, and find out there is new version of the package [email protected].
it's change from Google Drive API to Google Sheets API. It has many changes, but in my case now I can Batch / Bulk insert just with single line.
this is my code now.
const insertDataToSheet = async (data, sheet, msg) => {
try {
const result = await sheet.addRows(data)
if (result) return result
throw new Error(`${msg} Unkown Error`)
} catch (e) {
throw new Error(`${msg} Failed: ${e.message}`)
}
}
I just use sheet.addRows
and tada it's working.
My Problem is solved, but with promise I still need to learn,
Thanks for all of your suggestion / attention.