Pnpjs: Getting Parent Site Context

Created on 22 Jan 2019  路  3Comments  路  Source: pnp/pnpjs

Category

  • [ ] Enhancement
  • [ ] Bug
  • [x] Question
  • [ ] Documentation gap/issue

Version

Please specify what version of the library you are using: [1.2.8]

Please specify what version(s) of SharePoint you are targeting: [O365, Modern pages]

Expected / Desired Behavior / Question

Is there a way to get the parent site's context? I was trying to use the getParentWeb method but it doesn't seem to return the context. I'd like to be able to recursively get the parentWeb until I hit the root site. I was planning to do this by getting the parent web and loading its context into the sp.setup() method so that I could evoke it again to keep going back. Is there a way to do this?

Thanks!

code answered question

Most helpful comment

Hi @koltyakov,

Thank you! I'll give that one a go :)

All 3 comments

Hi @jcosta33,

Looks like using implicit Web/Site object creations is what you're looking for.

import { Web } from '@pnp/sp';
const web = new Web('[WEB_ABSOLUTE_URL]');

Hi @koltyakov,

Thank you! I'll give that one a go :)

Going to close this as answered. Please open a new issue should you still require assistance. Thanks!

Was this page helpful?
0 / 5 - 0 ratings