Skip to content

Instantly share code, notes, and snippets.

@naveenmaurya
Created May 12, 2020 15:38
Show Gist options
  • Save naveenmaurya/5a58e5516c0fa87ee6841282c48f413f to your computer and use it in GitHub Desktop.
Save naveenmaurya/5a58e5516c0fa87ee6841282c48f413f to your computer and use it in GitHub Desktop.
Get count of items/files in list/document library in SharePoint Online with SPFx
import { SPHttpClient, SPHttpClientResponse, SPHttpClientConfiguration } from '@microsoft/sp-http';
this.context.spHttpClient.get(`${this.context.pageContext.web.absoluteUrl}/_api/web/AppTiles`, SPHttpClient.configurations.v1)
.then((response: SPHttpClientResponse) => {
response.json()
.then((responseJSON: any) => {
console.log(responseJSON); // Gets all the list and document library details in JSON
})
.catch(error => {
console.log(error);
});
})
.catch(error => {
console.log(error);
});
// this.context refers to WebPartContext in the BaseClientSideWebPart class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment