I am trying to push into an existing array inside a callback function. It seems it is getting pushed inside the callback but the array variable is not being updated after completion. Does this have to do with async/await?
const writeRequest: WriteRequest[] = [];
try {
const responseBody = (await s3Client.send(command)).Body as Readable;
const stream = responseBody.pipe(stripBomStream());
Papa.parse(stream, {
header: true,
step: (result) => {
const item = createDynamoBody(result.data);
writeRequest.push(item);
},
});
console.log('writeRequest: ', writeRequest);
I tried using await and sync on the functions but it seems to not work.