Get component in the Microsoft Graph Toolkit
You can use
mgt-get to make any GET query from Microsoft Graph directly in your HTML. The component does not provide a default UI and requires that you write a template.
The following example shows the use of the
mgt-get component to display a user's emails. You can use the code editor to see how properties and attributes change the behavior of the component.
Properties and attributes
You can use several attributes to change the behavior of the component. The only required attribute is
|resource||resource||The resource to get from Microsoft Graph (for example,
|scopes||scopes||Optional array of strings if using the property or a comma delimited scope if using the attribute. The component will use these scopes (with a supported provider) to ensure that the user has consented to the right permission.|
|version||version||Optional API version to use when making the GET request. Default is
|max-pages||maxPages||Optional number of pages (for resources that support paging). Default is 3. Setting this value to 0 will get all pages.|
|polling-rate||pollingRate||Optional number of milliseconds. When set, the component will poll the request URI for updates in the defined interval. If using a delta query, polling will always query the delta API. The template will only refresh when the data changes.|
|cache-enabled||cacheEnabled||Optional Boolean. When set, it indicates that the response from the resource will be cached. Overriden if
|cache-invalidation-period||cacheInvalidationPeriod||Optional number of milliseconds. When set in combination with
|type||type||Optional type of the expected response. Default is
|N/A||response||Read-only response from Microsoft Graph if request was successful.|
|N/A||error||Read-only error from Microsoft Graph if request was not successful.|
|refresh(force?:boolean)||Call the method to refresh the data. By default, the UI will only update if the data changes. Pass
|Event||When is it emitted||Custom data||Cancelable||Bubbles||Works with custom template|
||Fired after the component loaded its data.||
For more information about the data returned in the
response property see the API reference of the API that you used in the
resource property of the Get component.
For more information about handling events, see events.
mgt-get component supports several templates that you can use to define the look and feel. To specify a template, include a
<template> element inside a component and set the
data-type value to one of the following.
|Data type||Data context||Description|
|default||The response from Microsoft Graph.||The default template is required to render the data coming from Microsoft Graph.|
|value||Data item from the returned
|error||The error from Microsoft Graph.||This template will be used if there is an error making the request.|
|loading||N/A||This template is used while the request is being made.|
|no-data||N/A||This template is used when the request returned no data.|
Microsoft Graph permissions
Permissions required by this component depend on the data that you want to retrieve with it from Microsoft Graph. For more information about permissions, see the Microsoft Graph permissions reference.
The control uses the global authentication provider described in the authentication documentation to fetch the required data.
To enable and configure the cache, use the
cacheInvalidationPeriod properties. By default, the
mgt-get component does not cache any responses.
|Object store||Cached data||Remarks|
||Complete response retrieved from Microsoft Graph for the query specified in the
See Caching for more details.