Pergunta

I try to fetch my properties using the sp.profiles.myProperties.get() from @pnp/sp.

It works on a hosted workbench but when I deployed the package and run it on Sharepoint site page I'm getting Error making HttpClient request in queryable [404] Not Found

Why is that so and how can I fix it?

Foi útil?

Solução

Looks like you are missing the inital setup which is necessary to determine the request URLs in SPFx context.

In your webpart.ts file, add the below piece of code:

import { sp } from "@pnp/sp/presets/all";

// ...

protected onInit(): Promise<void> {

  return super.onInit().then(_ => {

    // other init code may be present

    sp.setup({
      spfxContext: this.context
    });
  });
}

// ...

Reference - PnPJS getting started

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top