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

150
Views
Method returns undefined when called

I am trying to call a method from a service, within a react component, and call another method from the service within the component.

This is the method in the service:

  async GetAuthToken(){
    microsoftTeams.authentication.getAuthToken({
            
      successCallback: (result) => {
        return {
          client_id: "",
          client_secret: "",
          scope: "channel.readbasic.all files.read.all files.readwrite.all group.read.all group.readwrite.all user.read email offline_access openid profile",
          grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
          requested_token_use: "on_behalf_of",
          assertion: result,
        }
      },
      failureCallback(error) {
        console.log(error)
      },
    });
  }

And this is where I call it:

      httpClient.GetAuthToken().then((res)=>{
        httpClient.GetUser(res).then((res2)=> console.log(res2))
      });

When I console.log res, I get undefined, but when I log the result within the service, the value is there.

about 4 years ago · Juan Pablo Isaza
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!