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

92
Views
to extend an object returned from an async function

I'm trying to override a method of an object returned from an async function but get this error; dataProvider.getList is not a function

i tried to extend the object simply in this way but obviously is not correct

function App() {

    const [dataProvider, setDataProvider] = useState(null);
  
    useEffect(() => {
      const buildDataProvider = async () => {
  
        //this must to be called with await 
        const dataProvider = await buildHasuraProvider({
          clientOptions: { uri: 'http://localhost:8080/v1/graphql' }
        });
  
        //this object should be the same as above but with an overridend method  (getList)
        const  extendeDataProvider = {
          ...dataProvider,
           getList: (resource, params) => {
             if (resource === 'apikeys') {
               //implementation missing
             } else {
              // fallback to the default implementation  
              return dataProvider.getList(resource, params);
            }
          }
        }
  
        setDataProvider(() => extendeDataProvider);
      
      };
  
      buildDataProvider();
    }, []);
  
    if (!dataProvider) return <p>Loading...</p>;
  
    return (<Admin dataProvider={dataProvider} />)
  }
  
  export default App;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

i asume that the issue is with your fallback implementation in this line:

// fallback to the default implementation  
              return dataProvider.getList(resource, params);

u can also prove that by logging it this way -

console.log(typeof(dataProvider.getList))
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!