How to send API call body in batches using type script?
I have a large array of numbers, and my api call cannot handle it all. I need to send the body in batches to the POST call
here is my code
const body = "{
"arrayOfNum": [1,26,38,4,57,6,77,8,9,3333,55,3,55, ...etc]}"
export class Test {
async test1() : Promise<void> {
const response = await fetch(`${url}`, {
method: 'POST',
body: JSON.stringify(body),
headers: {'Content-Type': 'application/json', 'Authorization': `key=${API_KEY}`}
});
}
calling function “testFunc.ts”:
const test = new Test();
test.test1();
I can’t use await in my calling function as I will be running this function from npm run testFunc