Pregunta

I need to create a spfx webpart which fetch data from a list avaialble on different site collectionn. Ex: SPFx webpart deployed at https://test.sharepoint.com/sites/test1

List from where data need to be fetch is at site : https://test.sharepoint.com/sites/test2

¿Fue útil?

Solución

Did sample test.

The script would get data from another site collection while there is potential issue, SPFx use current user credential to access SharePoint data, so if current user has no permission to target site collection, there would be issue.

this.props.context.spHttpClient.get(`https://xxx.sharepoint.com/sites/modernteam/_api/web/lists/getbytitle('List1')/items?select=ID,Title`,
      SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
        response.json().then((responseJSON: any) => {
          // to do
        });
      });

So, you may consider to use search/Microsoft graph instead.

Search in SPFx

Call graph api in SPFx

Licenciado bajo: CC-BY-SA con atribución
scroll top