Thank you for reporting an issue, suggesting an enhancement, or asking a question. We appreciate your feedback - to help the team understand your
needs please complete the below template to ensure we have the details to help. Thanks!
Please check out the Docs to see if your question is already addressed there. This will help us ensure our documentation covers the most frequent questions.
Please specify what version of the library you are using: [ ]
Please specify what version(s) of SharePoint you are targeting: [ ]
If you are not using the latest release, please update and see if the issue is resolved before submitting an issue.
If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please
describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!
If you are reporting an issue please describe the behavior you expected to occur when performing the action. If you are making a
suggestion or asking a question delete this section.
If you are reporting an issue please describe the steps to reproduce the bug in sufficient detail to allow testing. If you are making
a suggestion or asking a question delete this section.
Delete this section after reading
Thank you for your feedback!
I am trying to user your @pnp/sp library in a SPFx webpart to get the current user.
In testing on the Workbench on the Hosted Server (SharePoint Online) this all works well..
When I have packaged the solution and deployed the webpart it is incorrectly including sitepages in the URL.
If I am using this incorrectly, could you let me know how I should get the current userId.
sp.site.rootWeb.currentUser.get().then(user => {
if (user) {
this.setState({userId: user.Id});
/* do other stuff here*/
}
});
If you are reporting an issue please describe the expected behavior. If you are suggesting an enhancement please
describe thoroughly the enhancement, how it can be achieved, and expected benefit. If you are asking a question, ask away!
Hi @AndrewCarterBreakwaterIT!
With SPFx, the context should be bound: https://pnp.github.io/pnpjs/documentation/getting-started/#using-pnpcommon-setup
Many thanks.. I did honestly read that .. but I wasn't sure whether it was required.. added this to the TS file and re published.. all good
Most helpful comment
Hi @AndrewCarterBreakwaterIT!
With SPFx, the context should be bound: https://pnp.github.io/pnpjs/documentation/getting-started/#using-pnpcommon-setup