Code to fetch top 5 items from SharePoint list using Rest API in SharePoint Framework (SPFx)
you can do using OData query in rest API request url by appending parameter ?top=5 to result set.https://contoso.sharepoint.com/sites/marketing/_api/web/lists/getbytitle('MyListTitle')/items?$top=5complete referece can be found at https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-rest-requests
We can use $top=5 to fetch top 5 items from a SharePoint list. We can use $top to retrieve upto 5000 items from a list. But if you need to fetch more than that you have to use recursive call.