Using the Microsoft Graph API
In Chapter 5, we demonstrated how to use the Microsoft Graph API to fetch a list of products coming from a SharePoint list in the ProductCatalogService class. In this section, we will simply summarize all the important steps.
As explained in the previous section, the very first step before calling the Microsoft Graph API is to approve the API permission scopes needed for the requested operation. In our case, we declare and approve the Sites.Read.All API permission.
Then, to perform requests against the Microsoft Graph API from an SPFx component, we need to get a client for the Microsoft Graph API to be able to make calls. We use the msGraphClientFactory.getClient("3") method from the this.context SPFx property to get one:
..
const msGraphClient = await this.context.msGraphClientFactory.getClient("3");
..			Finally, using that client instance, we use the appropriate /sites/{site-id}/lists/{list-id}/items endpoint URL and the...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                