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

153
Views
How can I access specific data from a promise?

On my code I search through a table in a supabase database. Eventually I'll search through using parameters given by user, but right now I'm just trying to retrieve the entire table.

const useSearch = (searchParams) => {
  let myObject = getTodos(searchParams).then((data) => {
    return data;
  }); 
      
  async function getTodos(searchParams) {
    let { data, error } = await supabase.from('deal_finder_deals').select('*');
    myObject = data;
    return data;
  }

  return {
    searchData: myObject,
  }

If I use console.log to check it to see what returns in myObject, it prints out like i want it to.

(2) [{…}, {…}]
0: {id: '0b0173c0-2621-4c69-abc6-b311b6848d8c', city: 'a', state: 'a', zip_code: 2, verified: true, …}
1: {id: '79f5990c-f52f-4c18-a64b-de80a81753a0', city: 'Abilene', state: 'TX', zip_code: 79354, verified: false, …}
length: 2

The issue is I want to import this into another class and it returns as a promise.

      let newData = await useSearch({data});
      console.log(newData);

The result:

{searchData: Promise}
searchData: Promise
[[Prototype]]: Promise
[[PromiseState]]: "fulfilled"
[[PromiseResult]]: Array(2)
0: {id: '0b0173c0-2621-4c69-abc6-b311b6848d8c', city: 'a', state: 'a', zip_code: 2, verified: true, …}
1: {id: '79f5990c-f52f-4c18-a64b-de80a81753a0', city: 'Abilene', state: 'TX', zip_code: 79354, verified: false, …}
length: 2
[[Prototype]]: Array(0)
[[Prototype]]: Object

Is there a way I can access the specific data that I want from a promise?

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!