Trying to get data from SharePoint online using spfx react ..
const { siteurl } = this.props;
let requestUrl = siteurl.concat(
"/_api/web/Lists/GetByTitle('Shoping%20CartItems')/items"
);
// Get users with givenName, surname, or displayName
this.context.spHttpClient
.get(requestUrl, SPHttpClient.configurations.v1)
.then(response => {
return response.json();
})
.then(json => {
// Prepare the output array
// Log the result in the console for testing purposes
console.log(json);
// Map the JSON response to the output array
json.value.map((item: any) => {});
})
.catch(error => {
console.error(error);
});
getting error --
ShopingCart.tsx:65 Uncaught (in promise) TypeError: Cannot read property 'get' of undefined at ShopingCart.fetchDatafromSharePointList (ShopingCart.tsx:65) at ShopingCart.