I am ugrading from sp-pnp-js and my solution uses the general function [List].fields.get() which the documentation suggests is still supported.
Only getByTitle(), getByInternalNameOrTitle() and getById() appear in the exported Fields class.
Any ole sp.web.lists.getById({GUID}).fields.get() should result in a TypeScript error.
Hi @Katli95, The below executes as expected without error for me. Can you provide a bit more detail around what you are doing? Perhaps a full code snippet that shows exactly what you are trying to do would be helpful here.
import { sp } from "@pnp/sp";
sp.web.lists.getByTitle("Documents").fields.get().then(f => {
console.log(JSON.stringify(f));
});
Hi @patrick-rodgers, thank you so much for the swift reply,
as I said, I am updating a solution to use @pnp/js instead of sp-pnp-js. I ran npm i @pnp/js (and uninstalled sp-pnp-js). I then changed my includes to import { sp } from "@pnp/sp";. Once I changed my function calls from pnp.sp.web... to sp.web... I started getting this odd error, which I now realize applies to Lists, Items and Fields. I'm getting warned that the simple .get() function seems to be missing on all these classes:



Small sidenote:
In code this is basically what I'm trying to do (which was supported with the old package), but as you can see above, even traditional calls are not working :/
func1(){
this.listInSP = sp.web.lists.getById(newList.Id);
}
func2(){
return this.listInSP.fields.get().then((fields: any[]) => {<custom mapping code>});
}
Another small sidenote:
I have already tried cleaning and re-building a couple of times but nothing changes.
Just to clarify we don't have a package "@pnp/js" - so perhaps that is the issue? You can see the getting started guide for installing the base packages here.
Yeah, totally that's my bad!
I meant npm i @pnp/sp do I need the @pnp/common or anything else along with @pnp/sp?
Okay, yeah, it got fixed as soon as I ran npm i @pnp/odata. I Didn't realize that there were these dependencies between the packages. I had intended to minimize the size of my application by including only what I needed. Is there anywhere I could have gone to see this dependency explained?
P.S. thanks for your help and all the good things you guys are doing for this community!
(love how quick your responses have been)
We outline the dependencies in the docs, you would have gotten an error when you did install on missing peer dependencies, or you can always check the package.json for the individual packages to see what each depends on. Thanks for your interest in the libraries!
Most helpful comment
Just to clarify we don't have a package "@pnp/js" - so perhaps that is the issue? You can see the getting started guide for installing the base packages here.