Skip to content

Commit cc965a8

Browse files
Merge pull request SharePoint#8396 from nanddeepn/patch-4
Updated code and fixed Style errors
2 parents c17bf0d + 9b4830e commit cc965a8

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

docs/spfx/web-parts/get-started/using-microsoft-graph-apis.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Building SharePoint Framework solutions, which use Microsoft Graph
33
description: Getting started tutorial on using Microsoft Graph with SharePoint Framework solutions
4-
ms.date: 6/21/2022
4+
ms.date: 8/24/2022
55
ms.localizationpriority: high
66
---
77

@@ -44,7 +44,8 @@ You can also follow these steps by watching this video on the Microsoft 365 Plat
4444

4545
- **Do you want to allow the tenant admin the choice of being able to deploy the solution to all sites immediately without running any feature deployment or adding apps in sites?**: Yes
4646
- **Which type of client-side component to create?**: WebPart
47-
- **Which framework would you like to use?**: No JavaScript framework
47+
- **What is your Web part name?**: MyFirstGraphWebPart
48+
- **Which framework would you like to use?**: No framework
4849

4950
At this point, Yeoman installs the required dependencies and scaffolds the solution files. Creation of the solution might take a few minutes. Yeoman scaffolds the project to include your **MyFirstGraphWebPart** web part as well.
5051

@@ -104,13 +105,13 @@ In this case, we'll modify the code to use Microsoft Graph to get access on the
104105
import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';
105106
```
106107

107-
1. Update the `render()` method as follows. Notice how we're using the `MSGraphClient` object for the Microsoft Graph calls. This object abstracts the access token handling, so that as a developer, you can concentrate on your business logic.
108+
1. Update the `render()` method as follows. Notice how we're using the `MSGraphClientV3` object for the Microsoft Graph calls. This object abstracts the access token handling, so that as a developer, you can concentrate on your business logic.
108109

109110
```typescript
110111
public render(): void {
111112
this.context.msGraphClientFactory
112113
.getClient('3')
113-
.then((client: MSGraphClient): void => {
114+
.then((client: MSGraphClientV3): void => {
114115
// get information about the current user from the Microsoft Graph
115116
client
116117
.api('/me/messages')
@@ -119,21 +120,17 @@ In this case, we'll modify the code to use Microsoft Graph to get access on the
119120
.get((error, messages: any, rawResponse?: any) => {
120121

121122
this.domElement.innerHTML = `
122-
<div class="${ styles.myFirstGraphWebPart}">
123-
<div class="${ styles.container}">
124-
<div class="${ styles.row}">
125-
<div class="${ styles.column}">
126-
<span class="${ styles.title}">Welcome to SharePoint!</span>
127-
<p class="${ styles.subTitle}">Use Microsoft Graph in SharePoint Framework.</p>
128-
<div id="spListContainer" />
129-
</div>
123+
<div class="${styles.myFirstGraphWebPart}">
124+
<div>
125+
<h3>Welcome to SharePoint Framework!</h3>
126+
<p>
127+
The SharePoint Framework (SPFx) is a extensibility model for Microsoft Viva, Microsoft Teams and SharePoint. It's the easiest way to extend Microsoft 365 with automatic Single Sign On, automatic hosting and industry standard tooling.
128+
</p>
130129
</div>
131-
</div>
132130
</div>`;
133131

134132
// List the latest emails based on what we got from the Graph
135133
this._renderEmailList(messages.value);
136-
137134
});
138135
});
139136
}
@@ -145,7 +142,7 @@ In this case, we'll modify the code to use Microsoft Graph to get access on the
145142
private _renderEmailList(messages: MicrosoftGraph.Message[]): void {
146143
let html: string = '';
147144
for (let index = 0; index < messages.length; index++) {
148-
html += `<p class="${styles.description}">Email ${index + 1} - ${escape(messages[index].subject)}</p>`;
145+
html += `<p class="${styles.welcome}">Email ${index + 1} - ${escape(messages[index].subject)}</p>`;
149146
}
150147

151148
// Add the emails to the placeholder

0 commit comments

Comments
 (0)