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

171
Views
Using data collected with axios later in the code

I am trying to collect a data with API with axios. But let's say I want to use this data later on the code but whenever I get out of the async code the returned data's status becomes pending. How to return data and store it to use whenever I want in code?

Here is the code:

const fetchData = async () => {
const response = await axios.get("http://www.omdbapi.com/", {
    params: {
        apikey: "a7aeae67",
        // s: `${searchBar.value}`
        s: "vam"

    }
})
}

console.log(fetchData())
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is the famous "blue function red function" argument. Once your code is doing something async it will always need to be accessed in async context.

So - it is impossible to access response from a non-async function and you would have to access it inside async functions by awaiting it in turn.

about 4 years ago · Juan Pablo Isaza Report
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!