Get all user properties using pnp js

In this article. I have explained how to get all the properties of the SharePoint user using pnp js.

For example the sample properties listed below:-

  • PictureURL
  • Department
  • Manager
  • FirstName
  • LastName

and lot more properties

In my previous i have written about how to retrieve current user properties using pnp js.

It will return some basic user properties like loginname, Title, etc…

Now let see how to done the it using PNP JS in the simplest way.

Import the PNP library from node

import pnp from "@pnp/pnpjs"; 

//For demo purpose hard-coded the loginname of the user

let loginName = "i:0#.f|membership|";

pnp.sp.profiles.getPropertiesFor(loginName).then(resp => {
        let props = {}{
            props[val.Key] = val.Value

        console.log("props", props)

It will return the successful response like below in JSON format

you can also use same JavaScript library of PNP Js in your normal JavaScript projects like Content editor webparts like below snippet

//Directly called library form CDN for reference

<script type="text/javascript" src=""/>

<script type="text/javascript">

var loginName = "i:0#.f|membership|";

        var props = {}{
            props[val.Key] = val.Value
        console.log("props", props)


Download it form CDN.

In my upcoming blogs let discuss more operations using PNP JS

Happy SharePointing !…

Add a Comment

Your email address will not be published. Required fields are marked *