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

273
Vistas
How can I get value from subscribe?

I tried to do this, but it doesn't work. Any help is appreciated thanks!

    export class OuterClass {
    let isEffectiveUrl = (url:string) => {
            let tmpRes:boolean
            this.http.get(url).subscribe((result) => {
                  tmpRes = Object.keys(result).length > 0;
                });
            return tmpRes;
          }
     }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're setting isEffectiveUrl to be a function, not the resulting evaluation. One way to do this would create a local variable and then execute your http.get within a function or one of your lifecycle hooks.

e.g.

export class OuterClass {

  isEffectiveUrl: boolean = false;

  testUrl(url: string): void {
    this.http.get(url).subscribe((result) => {
      this.isEffectiveUrl = Object.keys(result).length > 0;
    });
  }

}

Just remember, this is a reactive model. So what's being run in the subscribe block is asynchronous.

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