Not able to aggregate data returned from the twilio api

I’m trying to fetch the billing data from the Twilio API and save the returned value in a variable so that I can return it and display it in my web app. I know it’s related to async, I tried using async and await but wasn’t able to make it work.

const twilio = require("twilio");

client = twilio(

const filterOpts = {
  startDate: "2021-08-01",
  endDate: "2021-08-31",

let result = []
function getBillingData() {
  client.usage.records.each(filterOpts, async (record) => {
    let temp = await record;


When I try to run this, it prints []

Source: JavaSript – Stack Overflow

October 20, 2021
Category : News
Tags: asynchronous | javascript | node.js | promise | twilio

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.