spfxpnp-js

Using pnpjs 8.15 in SPFx - get() is not a function


New to pnpjs, using 8.15.0 trying to get a list of lists in a SPFx.

I'm getting error: TypeError: this.sp.web.lists.get is not a function. I have list item updates working in this same ts file. Assuming I am missing an import, can anyone advise.

import { spfi, SPFx } from "@pnp/sp"; //"@pnp/sp/presets/all" //
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";
import "@pnp/sp/files";
import "@pnp/sp/folders";
import { IField, IFieldAddResult, FieldTypes, IFieldInfo } from "@pnp/sp/fields/types";
import "@pnp/sp/lists/web";
import "@pnp/sp/fields";
import "@pnp/sp/items/get-all";
import {Web, IWeb} from "@pnp/sp/presets/all";

...

const lists: any[] = await sp.web.lists.filter('Hidden eq false').get();

Solution

  • There is no .get() since version 3 as far as I remember:

    const lists: any[] = await sp.web.lists.filter('Hidden eq false')();