Problem with SPFx Webparts (using PnP-JS-Core) on Sharepoint SitePages

Copper Contributor

Hi everyone,

 

I'm working with SPFx framework and I'm using the Pnp js library for REST requests. Everything was working fine since last week when REST requests stop working on sharepoint SitePages but not on the workbench.

When I debug, I notice that the endpoint url changed on the sitepages.

 

For example, i used to have 

https://<tenant>/_api/web/lists?$filter=BaseTemplate%20eq%20171

but now I'm getting

https:/<tenant>/SitePages/_api/web/lists?$filter=BaseTemplate%20eq%20171

and it's not working

 

Does anyone have the same problem and knows how to solve it?

 

Thank you.

9 Replies
Hi Jean,
I got the same problem.

When working on workbench it works fine. But when I use the client web part on a modern site page the REST web API requests don't work anymore.
Hi, this was reported a few days ago and is fixed in the latest beta. Can you give that a try using

npm install sp-pnp-js@beta --save

and let me know if that works? If so I am considering cutting an early release since this is a blocker for folks. Thanks!

P.S. In the future if you have an issue or find a bug please report it to the issues list - much easier to track and manage there.

Tried to reply earlier but didn't seem to post...

 

This was found and fixed earlier this week and is currently available in a beta release

 

install sp-pnp-js@beta --save

 

Please give it a try and if it works as expected we can look to cut a release later today since this is a blocker for folks and we don't want that.

 

As a side note - if you find issues please do use the issues list. That makes it much easier for us to see what problems folks might be having and address them. Thanks!

Actually, I just pushed 2.0.4 which includes this fix. It was an out of band update but this is a blocker so was needed. Please update to latest and let us know if you still see issues. Our bad on missing that bug in testing.

Thanks Patrick, works like expected!

Hi Patrick,

 

I'm having the same issue although I have tried both 2.0.4 and 2.0.5. Thanks in advance!

Hi Robin,

 

Which version did you use?

Actually I can't get the context directly as I wasn't using it in the webpart but component. It's working now after defining baseUrl in pnp.setup.