0

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();
Joe Johnston
  • 2,794
  • 2
  • 31
  • 54

2 Answers2

1

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

const lists: any[] = await sp.web.lists.filter('Hidden eq false')();
Nikolay
  • 10,752
  • 2
  • 23
  • 51
1

You don't need to use the get with the latest versions of the PnP JS library.

You can just use () instead of get().

You can follow the official PnP JS documentation for more information and examples: @pnp/sp/lists

Ganesh Sanap
  • 1,386
  • 1
  • 8
  • 18