@pnp/sp seems to be missing the .get() method

2.6k Views Asked by At

I am running into a strange (and hopefully very simple) issue where the .get() method does not seem to be defined in my spfx project. This is a typescript 2.4.2 project for creating an spfx webpart for SharePoint 2016 on prem.

  • The project was started using yo @microsoft/sharepoint
  • There was a fix applied to update some typescript 2.2.2 references as per instructions here
  • The dependencies for PnP were loaded:

    npm install @pnp/logging @pnp/common @pnp/odata @pnp/sp --save

  • Imports included

    import { sp, Web } from '@pnp/sp';

Within a function of my render() method I am trying to make a very simple call as follows

let web = new Web(this.context.pageContext.site.absoluteUrl);

return web.lists.getByTitle(this.properties.listName).fields.filter("Title eq 'Decision Status'").get();

I am getting an error that says Property 'get' does not exist on type 'Fields'. To try and make it even simpler I tried running

let web = new Web(this.context.pageContext.site.absoluteUrl);
web.get();

And I get a similar error saying 'get' does not exist on type 'Web'. The examples they show in the documentation show very similar code, but I can't determine what about my code is incorrect here.

2

There are 2 best solutions below

0
On

I was dealing with this issue, my solution was install this others dependencies with the same version.

@pnp/common
@pnp/logging
@pnp/odata
@pnp/sp

hope that helps for anyone with this problem!

0
On

If this issue is still relevant,check the version of the @pnp/sp installed. The latest one as of today is 1.2.9 and should support get