With the following React code you can
find an item from a list in SharePoint and then evaluate it
The underlying code is
const response = await this.context.spHttpClient.get("https://mySite.SharePoint.com/_api/web/lists/GetByTitle('myList')/Items?$filter=ID
eq '123'&$top=1“, SPHttpClient.configurations.v1);
|
Then you get the following 1-line Ein
trag of anarray
back
Call method:
The call can be executed using a method
like this
var p = await this.GetListItem("MySharePointListname","ID",123,"eq", 1 );
if(p.value[0].Pers_x00f6_nlich==true)
{
return true;
}
return false;
|
this method then returns the ListItem
public async GetListItem(listName: string, filterFieldName: string, filterFieldValue: string, comparator: string, top: number, rootbased: boolean = true): Promise<any> {
var apiUrl: string;
if (!rootbased) {
apiUrl = this.context.pageContext.web.absoluteUrl;
}
else {
apiUrl = this._baseUrl;
}
const response = await this.context.spHttpClient.get(apiUrl +
"/_api/web/lists/GetByTitle('" + listName + "')/Items?$filter=" + filterFieldName + " " + comparator + " '" + filterFieldValue + "'&$top=" + top, SPHttpClient.configurations.v1);
return response.json();
}
|
Im Visual Studio Code
Debugger : eines ListItems in SharePoint