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

195
Vistas
errorObj: unknown Object is of type 'unknown'

I am getting the error while using async, await in useEffect hook.

useEffect(() => {
if (contentLoader) {
      (async () => {
        try {
          const data = await promise;
          setData(data);
        } catch (errorObj) {
          if (!errorObj?.value) { //here i'm getting --> errorObj: unknown Object is of type 'unknown'.
            setError(errorObj);
            console.log(`loading document error: ${errorObj}`);
          }
        }
      })();
    } else // something else
}, [..])

whats wrong in my code.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're using TypeScript 4.4 or newer with [use-unknown-catch-variables] (https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#use-unknown-catch-variables) enabled.

The easiest fix, if you don't know the actual type of the error thrown, is to just tell TypeScript that it's any, not unknown.

catch (errorObj) {

->

catch (errorObj: any) {
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