Forum Discussion
Americo Perez
Mar 01, 2019Iron Contributor
SPFx how to get the current page title?
Hi, I am trying to use SPFx and @pnp/sp to get the title of the current news page, I mean when I open a news post I would like to retrieve the title of the news post. Actually the site pages libr...
- Mar 02, 2019
You can try in this way, using pnpjs and listitemid (number)
var resultData: any = await sp.web.lists.getByTitle("Site Pages") .items.getById(15) .select("Tags") .get(); return await resultData.Tags;
Cheers
Federico
Mar 02, 2019
You can try in this way, using pnpjs and listitemid (number)
var resultData: any = await sp.web.lists.getByTitle("Site Pages") .items.getById(15) .select("Tags") .get(); return await resultData.Tags;
Cheers
Federico
Americo Perez
Mar 02, 2019Iron Contributor
Thanks Federico,
What is the 15 in the getById?
Right now I am getting an 404 error :-(
Regards!
- Mar 02, 2019
listitemid (number), your this.props.context.pageContext.listItem.id
Cheers
Federico
- Americo PerezMar 02, 2019Iron Contributor
I understand.
I did some changes and I am getting the corresponding tags.
Thanks for your help!!
Regards!
- Mar 02, 2019
welcome :)
Federico