Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
(Javascript How to use a function result as a parameter in another function

I'm currently trying to write a script to be embedded in a HTML file that:

  1. Calls an API for a ticket
  2. Uses the ticket in a subsequent function to display a dashboard

I'm kinda new to Javascript and learning as I go, but I'm getting a bit lost on this one :)

Function1 below shows my efforts to store the ticket as a variable. However, when I try to use the ticket in Function2, it appears that the API call hasn't finished yet.

How can I make Function2 wait for Function1 to complete before processing?

Function1

function getTix() {
    return new Promise(function (resolve) {
        axios.get(api_url)
            .then(response => {
                resolve(response.data.ticket);
                console.log(response.data.ticket);
                myticket = response.data.ticket;
            })
            .catch(error => console.error(error));
    });
}


Function2

function showDashboard() {
    const dash_div = document.getElementById('displaydash');
    const dash_url = "https://server.com/" + myticket;
    
    viz = new Viz(dash_div, dash_url);
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!