SOLVED

PnP-JS-Core open web by url?

%3CLINGO-SUB%20id%3D%22lingo-sub-33401%22%20slang%3D%22en-US%22%3EPnP-JS-Core%20open%20web%20by%20url%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33401%22%20slang%3D%22en-US%22%3E%3CP%3EEvery%20example%20I%20see%20of%26nbsp%3BPnP-JS-Core%20uses%20the%20current%20web.%20How%20can%20I%20open%20a%20list%20from%20another%20web%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33589%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20PnP-JS-Core%20open%20web%20by%20url%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33589%22%20slang%3D%22en-US%22%3E%3CP%3EFor%20anyone%20else%20searching%20for%20this.%20Here's%20how%20you%20do%20it%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%3Evar%20w%20%3D%20new%20%24pnp.Web(%22%2Fnews%22)%3B%0Aw.lists.getByTitle(%22Alerts%22)....%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33464%22%20slang%3D%22en-US%22%3ERe%3A%20RE%3A%20PnP-JS-Core%20open%20web%20by%20url%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33464%22%20slang%3D%22en-US%22%3E%3CP%3EThat's%20how%20you%20do%20it%20with%20CSOM%2C%20but%20PNP-Core%20is%20a%20wrapper%20for%20the%20REST%20services.%20Makes%20lots%20of%20things%20easier%2C%20but%20documentation%20is%20sketchy.%20Thanks%20for%20the%20response.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-33435%22%20slang%3D%22en-US%22%3ERE%3A%20PnP-JS-Core%20open%20web%20by%20url%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-33435%22%20slang%3D%22en-US%22%3Ehave%20not%20seen%20the%20code%20but%20i%20guess%20you%20need%20to%20create%20your%20own%20clientcontext%20with%20site%20url%20and%20then%20go%20to%20the%20correct%20web.%3C%2FLINGO-BODY%3E
New Contributor

Every example I see of PnP-JS-Core uses the current web. How can I open a list from another web?

3 Replies
have not seen the code but i guess you need to create your own clientcontext with site url and then go to the correct web.

That's how you do it with CSOM, but PNP-Core is a wrapper for the REST services. Makes lots of things easier, but documentation is sketchy. Thanks for the response.

best response confirmed by Clifford Adams (New Contributor)
Solution

For anyone else searching for this. Here's how you do it:

var w = new $pnp.Web("/news");
w.lists.getByTitle("Alerts")....