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

103
Views
Returned data from function is Promise (fulfilled) data
defaultValue = getFile(getCurrent.value[name]) 

Function getFile:

const getFile = async (id) => {
  const data = store.dispatch(Actions.FILE, id).then(() => {
    const data = [{ description: store.getters.currentFile.description, url: 'https://test.com/uploads/'+ store.getters.currentFile.name }]
    return data
  })
  return data
}

If I console.log(defaultValue): I see the following output; enter image description here

But I need a array instead of this Promise thing. How to solve?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have to use await keyword on your getFile to retrieve value front promise because your getFile returns Promise.

async function yourFunc() {
   defaultValue = await getFile(getCurrent.value[name])
   // do whatever you want
}
about 4 years ago · Juan Pablo Isaza Report

0

You need to use the await keyword

const getFile = async (id) => {
   await store.dispatch(Actions.FILE, id);
   return  [{ description: store.getters.currentFile.description, url: 'https://test.com/uploads/'+ store.getters.currentFile.name }]
}

and then await the call to getFile too

defaultValue = await getFile(getCurrent.value[name]) 
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!