Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

81
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.

7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.