sharepoint-onlinesharepointframework

Unable to List All SharePoint Online Lists Using SharePoint SPFX Framework


I'm new to SharePoint SPFX development. As I am new to SharePoint SPFx, I was trying the below Microsoft Official Tutorial Connect your client-side web part to SharePoint (Hello World part 2) .

I successfully completed Part 01 of the tutorial series, Build your first SharePoint client-side web part (Hello World part 1) 

When I'm following Part 02 I got stuck at the below 2 methods

01

 private _renderListAsync(): void {
    this._getListData()
      .then((response) => {
        this._renderList(response.value);
      })
      .catch(() => {});
  }

The error is in line 4 (response.value), which is 'Argument of type 'ISPLists[]' is not assignable to parameter of type 'ISPList[]'. Type 'ISPLists' is missing the following properties from type 'ISPList': Title, Idts(2345)'

Also in the same method line 6 (.catch(() => {});), which is 'Unexpected empty arrow function.eslint@typescript-eslint/no-empty-function'

02

private _getListData(): Promise<ISPLists> {
    return this.context.spHttpClient.get(`${this.context.pageContext.web.absoluteUrl}/_api/web/lists?$filter=Hidden eq false`, SPHttpClient.configurations.v1)
      .then((response: SPHttpClientResponse) => {
        return response.json();
      })
      .catch(() => {}); 
  }

The error is in line 6 (.catch(() => {});), whcich is Unexpected empty arrow function.eslint@typescript-eslint/no-empty-function

I tried many threads but didn't get an answer.

I'm using SharePoint Online, NodeJs 16.20.0, NPM 8.19.4 without using any front-end framework like React or Angular.

Please refer to the below link for the source code for the solution. Souce code Could you please help me to solve this issue?

Best regards, ChiranthakaJ


Solution

  • I found the answer to the questions.

    1. For the issue in '.catch(() => {});' use '.catch((err) => { console.log(err); });'

    2. For the issue 'ISPList[]'. Type 'ISPLists' is missing the following properties from type 'ISPList': Title, Idts(2345)' complete the source code by following the instructions till the end of the tutorial page 2 and the issue will automatically will disappear.