0
votes

I don't know of a good example that shows how to retrieve users in my tenant using a people picker and @pnp/sp.

I have tried using the @pnp/sp manuals on GitHub. Also several tutorials but none mention how to query an Office 365 tenant.

Here's the people picker in the render:

 <PeoplePicker
            context={this.props.context}
            titleText="People Picker"
            personSelectionLimit={3}
            groupName={''}
            showtooltip={true}
            isRequired={true}
            disabled={true}
            selectedItems={this._getPeoplePickerItems}
            showHiddenInUI={false}
            principalTypes={[PrincipalType.User]}
            resolveDelay={1000} 
            />  

Here's my empty function, ready and waiting for that magic line of code.

private _getPeoplePickerItems(items: any[]) {
    console.log('Items:', items);
  }

I expect the people picker to query my tenant and show me users in my tenant. At the moment it shows Group could not be found, but I understand why of course.

1

1 Answers

1
votes

Get list of users, calling /_api/_web/siteusers

Or:

$pnp.sp.web.siteUsers.get().then(function(data) {
    //to do
});