0

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

0

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

2
  • In this we gave hard core link, is there any other way we can achieve this without giving any link directly? – Ashutosh Agarwal May 28 '20 at 3:52
  • You may create a custom property so you could set the url dynamically. – Lee_MSFT May 28 '20 at 5:09

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.