Forum Discussion
Mccartc11025
Jun 08, 2023Copper Contributor
SPFx webpart doesn't work after deploy
Hi, We have a webpart that when run on the workbench works as expected. Its using PnP to get the user profile and then searches a list to find list items. The webpart fails with the call to the Pr...
ganeshsanap
Jun 09, 2023MVP
Mccartc11025 did you supply the web part context to PnP JS library while using it within SPFx?
Example:
import pnp from "sp-pnp-js";
// ...
public onInit(): Promise<void> {
return super.onInit().then(_ => {
pnp.setup({
spfxContext: this.context
});
});
}
Above code might differ based on the version of PnP JS you are using. Check below threads for more details:
Also, make sure you are using --ship while bundling and packaging the solution, like:
gulp bundle --ship
gulp package-solution --ship
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.