Please specify what version of the library you are using: [1.2.7]
Please specify what version(s) of SharePoint you are targeting: [Modern O365]
I'd like to use the getMenuState method to retrieve the navigation of the root site collection. This method only exists inside de sp object, which is set up like this:
sp.setup({
spfxContext: context
});
I can use the getRootWeb method but that doesn't give me that sp object where I can access the method I need. Is there a way to set up the sp with the root site collection context? What can I do here?
Thank you!
How about explicit object creation?
import { NavigationService } from '@pnp/sp';
const siteAbsUrl = 'https://contoso.sharepoint.com/sites/siiite';
const navigation = new NavigationService(siteAbsUrl);
navigation.getMenuState().then(console.log);
Thank you for the quick response! I'm having some trouble though... It seems like it doesn't matter what string I pass into the NavigationService, it'll always return the local navigation. As you can see in this screenshot, I'm passing in an URL to a valid site but the output includes properties pointing to the site where the solution is deployed and the navigation is the local one as well.

Updated the class to support what you want to do. It is rolled into the #533 PR.
Any ETA on when this fix will be released?
It was released Friday as indicated in the Chanelog and the milestone in the linked PR.
Most helpful comment
It was released Friday as indicated in the Chanelog and the milestone in the linked PR.