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;
};
Word
Word
A family of Microsoft word processing software products for creating web, email, and print documents.
753 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,720 questions
0 comments No comments
{count} votes