Now we are ready to save the data to the SharePoint list. We are going to do it using REST API but, to help us out, we are using SPHttpClient class. If we are running on a local workbench, that will not work, so we need to know the environment type before trying to save the data and act accordingly. Open FeedbackWebPart.ts and insert the following import statement after the other import statements at the start of the file:
import { SPHttpClient, ISPHttpClientOptions, SPHttpClientResponse } from '@microsoft/sp-http';
import { Environment, EnvironmentType } from '@microsoft/sp-core-library';
Replace the sendFeedback function with the following code.
private sendFeedback(): void {
this.context.statusRenderer.clearError(this.domElement);
const paragraphElement: HTMLParagraphElement =
this.domElement.getElementsByClassName(styles.successIndicator)[0] as HTMLParagraphElement;
paragraphElement.innerHTML = "";
if (this...