Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda