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

Microsoft 365 and Office SharePoint Development
Microsoft 365 and Office SharePoint For business Windows
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.