Inside my React SPFx web part, i need to get the current SharePoint Page Title, to do so i need to run this API Call:-
let listTitle: string = this.props.context.pageContext.list.title;
let pageItemId: number = this.props.context.pageContext.listItem.id;
let url = `${this.props.context.pageContext.web.absoluteUrl}/_api/lists/getbytitle('${listTitle}')/items(${pageItemId})?$select=ID,Title`;
so how i can call the above URL and get the string it should return?
Thanks
I tried the following but the function will return null
private GetPageTitle()
{ let listTitle: string = this.props.context.pageContext.list.title;
let pageItemId: number = this.props.context.pageContext.listItem.id;
let url = `${this.props.context.pageContext.web.absoluteUrl}/_api/lists/getbytitle('${listTitle}')/items(${pageItemId})?$Title`;
return (RelatedTopics.getSPData(this.client, url));
}