pnpJS not working as expected

Hi
trying to get list data from different Site Collection via

let web = new Web("https://mysite");
pnp.sp.web.lists.getByTitle('list title').items.select('Title').get().then(function (items) {
    console.log('items');
    });

I always get a "Uncaught ReferenceError: Web is not defined" Is there maybe a missing library in my installation, is it possible to check that?

I'm using the script in an external script file.

Hello @Alex,

How do you call this code? From the browser console or on button click?
If so, you should define Web globally like so:

image

window.pnp = pnp;
window.Web = Web;

thanks a lot, this is working

1 Like