I use PnP for getting SharePoint list item. But I don't really know, how use the result of my function.

I wish to get items of my SharePoint list using PnP and assign it to my list.

My code don't work:

  public render(): void {

    const element: React.ReactElement<IFaqProps > = React.createElement(
        description: this.properties.description,
        items :  this.getFaqList()

    ReactDom.render(element, this.domElement);

    let ListFaq : IExampleItem[];
/*= [{Question:"question",Reponse:"response", Categorie :{Title : "SharePoint"} , Langue:"fr"},
{Question:"question",Reponse:"response", Categorie :{Title : "OnDrive"} , Langue:"fr"}];*/

       .then((response) => {
         response.forEach((item: IExampleItem) => {
          return ListFaq.push(item);
return ListFaq;

   public _getListData(): Promise<IExampleItem[]> {
    return sp.web.lists.getByTitle("FAQ_List").items
    .select("Question", "Reponse","Categorie/Title", "Langue")
    .then((response) => {

       return response;

export interface IFaqProps {
  description: string;
  items: IExampleItem[];
export type IExampleItem = { Question: string; Reponse: string; Categorie: {Title :string}; Langue: string };

Debug your code - set a breakpoint on return response; then check the result inside of response object. Add another then to your promise i.e. .then((items) => { console.log(items);}) then do whatever you want with the data in your response.


I suggest you store the result in the state of the componment and put the request in componentDidMount method as it's a async request. You can take a reference of below code:

const response = await sp.web.lists.getByTitle("FAQ_List").items
    .select("Question", "Reponse","Categorie/Title", "Langue")

const items: IExampleItem[] = response.map(item => {
        return {
          Title: item.Question,
          Size: item.Categorie,
          Name: item.Langue

this.setState({ ...this.state, items });

For more details, you may take a reference of below sample:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.