import { SPHttpClient } from '@microsoft/sp-http' ; export class ListItemRepository { constructor ( protected SiteUrl , protected SPClient ) { } param filterText param listId param internalColumnName param keyInternalColumnName param webUrl param top param orderBy public async getListItemsByFilterClause ( filterText , listId , internalColumnName , keyInternalColumnName ? , webUrl ? , top ? , orderBy ? ) { try { const webAbsoluteUrl = ! webUrl ? this . SiteUrl : webUrl ; let apiUrl = `${ webAbsoluteUrl }/_api/web/lists('${ listId }')/items?$select=${ keyInternalColumnName || 'Id' },${ internalColumnName }&$filter=${ filterText }&$top=${ top }` ; if ( orderBy ) { apiUrl += `&$orderBy=${ orderBy }` ; } const data = await this . SPClient . get ( apiUrl , SPHttpClient . configurations . v1 ) ; if ( data . ok ) { const results = await data . json ( ) ; if ( results && results . value && results . value . length > 0 ) { return results . value ; } } return [ ] ; } catch ( error ) { return Promise . reject ( error ) ; } } }