SharePoint Online - Possible options to access data in SPFx
To access and interact with SharePoint data within a SPFx-based solutions you have multiple options. You can just use the raw SharePoint REST API with the Browser built-in fetch-Method or you can use the Microsoft Graph-API. To compare the different options I have prepared a overview to showcase the access methods.
Check my short overview poster with some pros and cons about the possible data access options within SPFx-Solutions & sample code & data format response.
The overview compares the following options:
- Plain raw HTTP via fetch API (call SharePoint API REST endpoint directly)
- SPHttpClient - SPFx context API (don't worry about authentication)
- Microsoft Graph (seamless integration)
- PnPjs - Library (High level fluent API)
For example I need often different options depending on the requirements. I like the MS-Graph option because you can try the calls directly online with the Graph-Explorer (https://lnkd.in/eSNKs-wk).
For the other options you can use Postman to test your calls.
To try out all options by yourself you can use my GitHub starter project. This project includes side‑by‑side implementations using all of the options
Ressources
Kommentare