import ITenantDataProvider from "./ITenantDataProvider" ; import { ApplicationCustomizerContext } from "@microsoft/sp-application-base" ; import { SPHttpClient } from "@microsoft/sp-http" ; import { Text } from "@microsoft/sp-core-library" ; import { Logger } from "@pnp/logging" ; class TenantDataProvider implements ITenantDataProvider { private _context : ApplicationCustomizerContext ; constructor ( context ) { this . _context = context ; } param key public async getTenantPropertyValue ( key ) { const url = Text . format ( "{0}/_api/web/GetStorageEntity('{1}')" , this . _context . pageContext . site . absoluteUrl , key ) ; try { const response = await this . _context . spHttpClient . get ( url , SPHttpClient . configurations . v1 ) ; const data = await response . json ( ) ; if ( response . ok ) { return data . Value ; } else { const errorDetails = data [ "ExceptionMessage" ] ; throw ( errorDetails ) ; } } catch ( error ) { Logger . write ( Text . format ( "[TenantDataProvider_getTenantProperty]: Error: {0}" , error ) ) ; } } } export default TenantDataProvider ;