How to properly set up the context and use "@pnp/sp" in Office Word add in

Razic Armin 0 Reputation points
2023-04-13T10:21:47.4733333+00:00

Hi there, I have generated an Office word add-in the react-spfx template using yo man generator. I am trying to auto populate the word header with the managed properties and other metadata related to the document in SP library. But having trouble getting the right pnp context setup. Thank you.

export  const  getSP  = (context?: ISPFXContext): SPFI => {
  if (_sp === null && context !== null) {
    _sp = spfi().using(SPFx(context)).using(PnPLogging(LogLevel.Warning));
  }
  return _sp;
};
Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Word | For business | Windows
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.