I have a SharePoint SPFx react webapp that I'm working on. I'm trying to get the SharePoint URL. For example:
https://mysite.sharepoint.com/sites/sitename/SitePages/Home.aspx#/
So I want to get https://mysite.sharepoint.com/sites/sitename
I've tried using references from here: Get Site Collection full URL using javascript and spfx-how-use-site-url-from-current-page-context-in-react-spfx-solution
The issue I'm having is I'm using the older sp-pnp-js library so all the examples I found online reference the newer pnpJS library.
So this.context.pageContext.web.absoluteUrl and spHttpClient do not work with the older sp-pnp-js library
'context' is deprecatederror and the page fails. did this in mycomponentDidMountand thenconsole.log(web)– hisusu32 Oct 13 '21 at 22:06const element: React.ReactElement<IFormProps > = React.createElement( Form, { context: this.context } )– ayodele Oct 14 '21 at 10:47IWebPartContextthat would be why you are getting that error as it is deprecated. There is a newer interfaceWebPartContext. In my case my webpart props looks like thisexport interface IFormWebPartProps { description: string; listName: string; context: WebPartContext; }– ayodele Oct 14 '21 at 10:53