trying to retrieve list items via get method of spHttpClient object in SPFx webpart project.
Here code piece;
private readItems(): void {
this.setState({
status: 'Loading all items...',
items: []
});
this.props.httpClient.get(`${this.siteUrl}/_api/web/lists/getbytitle('${this.props.listName}')/items?$select=Title,Id`,
SPHttpClientConfigurations.v1)
.then((response: Response): Promise<{ value: IListItem[] }> => {
debugger;
return response.json();
})
.then((response: { value: IListItem[] }): void => {
debugger;
this.setState({
status: `Successfully loaded ${response.value.length} items`,
items: response.value
});
}, (error: any): void => {
this.setState({
status: 'Loading all items failed with error: ' + error,
items: []
});
});
}
when this function triggered here is the response from server;
Message is obvious, but I really need to get list items in this web address. how can I achieve it ?
I created this project with yeoman generator("yo @microsoft/sharepoint") is there any configuration to make it run http:// instead of https://
as you know default address of application is "https://localhost:4321/temp/workbench.html"