Skip to content

Import Web is not working for accessing another site in SPFX #790

@Hub-GHS

Description

@Hub-GHS

Type of issue

The below code works fine on lists in the same site collection, but not on lists in a different site collection

Using the below in package.json

"@pnp/common": "1.3.3",
"@pnp/logging" :"1.3.3",

"@pnp/odata":"1.3.3",

"@pnp/sp":"1.3.3"


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

const targetSiteCollectionUrl = "https://anothersitecollectionURL";

const web = new Web(targetSiteCollectionUrl);

sp.setup({
sp: {
baseUrl: targetSiteCollectionUrl,
},
});

let listItems = await web.lists.getByTitle("TeamInfo").items.get();

console.log(listItems.length);


My environment

Windows 10 64-bit
Node Version v10.24.1
NPM Version - 6.14.2
yo - 3.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions