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

265
Views
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 answers
Answer question

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 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!