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

586
Vistas
How to check if Axios response data is empty

How to check if axios response is empty. Sometimes my response. data will be [ ]. Currently, it aways alerts "data there" is there a better way to do this than response.data.length >= 1

return await axios
    .get(url.rest_api + '/team_members', {
      params: {
        primaryOwner: firebase.auth().currentUser.uid,
        teamMemberEmail: emailText,
      },
    })
    .then(response => {
      if (response.data) {
        alert('data there');
      } else {
        alert('nothing here');
      }
      return response.data;
    })
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you can check the availability with: const isDataAvailable = response.data && response.data.length;

about 4 years ago · Juan Pablo Isaza Denunciar

0

According to the Response Schema, response.data is an instance of an Object (please correct me if I'm wrong). So we can check if data is not an empty string AND if it's constructor is and instance of an Object.

That's how I check it

if (response.data !== '' && response.data.constructor === Object) {
   //do something
}

Never fails (for me at least)

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