Angelo Guarino
Angelo Guarino

Reputation: 101

SPFX pnpjs spfi().using(SPFx(this.props.context)) doesn't get web object

i have two client webparts in a page. both of them use pnpjs to retreive list items. the problem is that one webpart correctly loads sp.web while the other doesn't. both use the same code to instantiate the element.

this.sp = spfi().using(SPFx(this.props.context)); //props.context coming from webpart.ts

what i get in both is:

1 (working)

enter image description here

2 (not working)

enter image description here

can anyone solve the mistery? :) thanks everyone!

Upvotes: 2

Views: 2611

Answers (1)

Angelo Guarino
Angelo Guarino

Reputation: 101

i found out that if i import spfi and SPFx from '@pnp/sp/presets/all' instead of "@pnp/sp" it then works. i'm not that good to know exactly the reason but it now works, if this can help anyone! :)

Upvotes: 5

Related Questions