spfx – How to get users job title using pnp-sp-js Sharepoint 2019 on-premise

You can get the Job Title of user using SharePoint REST API like:

<site url>/_api/web/lists/getByTitle('List Name')/items?$select=Title,Author/JobTitle&$expand=Author

Where Author is internal name of Person or Group field.

Similarly you can expand the person or group field using SP PnP JS and select the Job Title of user, like:

import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/items";

const items = await sp.web.lists.getByTitle("List Name").items.select("Title", "Author/JobTitle").expand("Author").get();
console.log(items);