1

I'm trying to get the user context in my React webpart and am getting 404's when requesting: https://localhost:4321/_api/web/currentuser

This is the part of the code that fetches the current user:

private GetUserProperties(): void {
/*
pnp.setup({
  spfxContext: this.context
});
 */

pnp.sp.web.currentUser.get().then((r: CurrentUser) => {
  console.log('CURRENT USER', r);
});

}

This was setup as a Sharepoint online application. I've tried several different solutions with no luck.

0

You are trying to get user details through local machine. The API you are using is a SharePoint REST API and for that you will need a SharePoint site and access to the site to get the current user details by using the following URL:

https://Your_SharePoint_Site_Url/_api/web/currentuser

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.