I am trying to call the dummy API from SPFX, but I am getting an error, Failed to fetch
,
this.context.httpClient
.get("http://dummy.restapiexample.com/api/v1/employees", HttpClient.configurations.v1)
.then((res: HttpClientResponse): Promise<any> => {
alert("");
return res.json();
})
.then((data: any): void => {
alert("");
// Process your data here
}, (err: any): void => {
// Handle error here
});
How can I fix this problem?
https
and you are calling insecurehttp
request. So the request will get blocked on SharePoint workbench. Instead you can try calling GET call on any of your SharePoint list likesiteUrl/_api/web/lists/getbytitle('ListName')/items
.