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.

| improve this answer | |

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.