I already asked this question regarding SPFx extensions.

But now I have the same problem I had in that question, but for a SPFx Web part. I use the exact same _getUserInformation() method as mentioned in the answer and which worked for my extension.

private _getUserInformation() : Promise<any> {
  const res = this.context.msGraphClientFactory
    .then((client: MSGraphClient): void => {
      .get((error, response: MicrosoftGraph.User, rawResponse?: any) => {
        // do something

  return Promise.resolve<any>(res);

And I call it like that:

public async render(): Promise<void> {
  await this._getUserInformation();

But _doOtherStuff() gets called before the the _getUserInformation()-method is finished. I know it seems to be the same question as in my other issue, and probably it is, but why is it like that? I really used the exact same code, but this time in a web part, not an extension.

1 Answer 1


The problem here is that you are returning a resolved promise, it basically tells the caller "hey I'm done", which in your case might or might not be true depending on the timing of things.
I suggest you return res right away without wrapping it in a returned promise. Or you could switch to the async/await syntax for this method as well to be consistent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.