function chunkArrayInGroups(arr, size) {
var newArr = [];
for (var i = 0; i < arr.length; i += size) {
newArr.push(arr.slice(i, i + size));
}
return newArr;
}
Áp dụng trong App
var pi = await chunkArrayInGroups(sub_array2, 100).reduce(async (promise, arr) => {
await promise;
var body2 = {
'app': appid,
'records': arr
};
var resp = await kintone.api('/k/v1/records', 'POST', body2);
console.log(resp);
}, Promise.resolve());
// App 3412