SPFx get lists items using REST API in sharepoint

lee sharepoint 80 Reputation points
2024-05-30T19:13:59.3766667+00:00

We are trying to create a spfx webpart using rest api. And we are following the steps

Connect your web part to SharePoint.

After deploy the solution, I get the following error

Error TS6133: '_getListData' is declared but its value is never read. Error @typescript-eslint/no-empty-function: Unexpected empty arrow function.

Please help fix

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,150 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,783 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 33,176 Reputation points Microsoft Vendor
    2024-05-31T02:19:37.28+00:00

    Hi @lee sharepoint ,

    If you are new to SPFx and started learning it, my suggestion is to use the PnP JS, the more convenient way to work with SharePoint list, libraries, user profile, taxonomy etc..

    private GetLists():Promise<any>{
        return sp.web.lists.filter(‘Hidden eq false’).get().then((data) =>{
          console.log(“Total number of
    lists are “ + data.length);
          return data;
        });
    

    Below are the few links for your reference :


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful