MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    Multiple API Requests

    Scheduled Pinned Locked Moved Development
    3 Posts 2 Posters 1.5k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W Offline
      winstonma
      last edited by

      I created a module that would display the estimated time of arrival (ETA) in a particular stop. But that can’t be done using a single API. Here is what I need

      • At start time I need to obtain the list of routes by calling an API

      • Every single minute for each route I need to collect the ETA for each route (Multiple API calls). And then update the grid accordingly.

      I have done the first part but have no idea how to do the second part. Thanks for the help.

      1 Reply Last reply Reply Quote 0
      • yawnsY Offline
        yawns Moderator
        last edited by

        Well, of course you need two different functions or one function with multiple parameters.

        Your first function fills an array with routes. Afterwards you check if this array is already set (and maybe if less than 24 hours passed) and if this is true you skip the first function but call the second function which fills another array of data. Your getDom checks both arrays and skips the ETA stuff until the array is filled.

        1 Reply Last reply Reply Quote 0
        • W Offline
          winstonma
          last edited by winstonma

          Thanks for the reply.

          I think my major question is, how can I make multiple asynchronous API calls (for obtaining the Stop info as well as obtaining the ETA for each route). Any example would be a great (pipe requests).

          Thanks for the help.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy