1

I’m starting a new job and been tasked with creating a react based application which will be built in SharePoint and retrieve data using Microsoft Graph. I am new to this and am struggling with understanding how to make calls in typescript/the structure of the code.

I’ve Done the hello world tutorials Microsoft graph offers. I prefer to learn by having examples to follow so I wonder if anyone have recommendations on such examples I can look into.

1 Answer 1

1

You can follow below Microsoft official documentations to use Microsoft Graph in react based SharePoint framework (SPFx) web parts:

  1. Use the MSGraphClient to connect to Microsoft Graph
  2. Consume the Microsoft Graph in the SharePoint Framework

Also, check below SPFx samples submitted by community members to GitHub repository. Many of these samples uses Microsoft graph resources:

sp-dev-fx-webparts samples

8
  • Thank you, ill check those out. Can you direct me to how I can create a client instance that I can use to make graph requests with?
    – OLGJ
    Commented Jun 16, 2022 at 13:13
  • Check first link in my answer, it explains how to create & use the MS Graph client to make MS graph requests. Commented Jun 16, 2022 at 13:31
  • Yes thank you, I've read that link and I'm able to make for instance a get request. To be more specific I was trying to set up an instance of client so I don't have to write this.context.msGraphClientFactory.getClient().then((client: MSGraphClient) every time I want to make a request, but rather use a variable or something I can call instead? Something which translates to what they do here in step 3 (actually they do it in step 2 but I'm not able to follow it): github.com/microsoftgraph/msgraph-sdk-javascript
    – OLGJ
    Commented Jun 16, 2022 at 14:28
  • 1
    I'm so sorry, I thought I had done that. Very grateful for your help :)
    – OLGJ
    Commented Jun 17, 2022 at 7:02
  • 1
    No problem. Let me know if above example works for you. We can continue our chat in your another question at: sharepoint.stackexchange.com/questions/302378/… Commented Jun 17, 2022 at 7:03

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.