Skip to content

Instantly share code, notes, and snippets.

@Fabianopb
Created September 17, 2018 17:56
Show Gist options
  • Save Fabianopb/9f5831a794d3a1aab710b46c24c2e006 to your computer and use it in GitHub Desktop.
Save Fabianopb/9f5831a794d3a1aab710b46c24c2e006 to your computer and use it in GitHub Desktop.
private method in the App.tsx for express-react-ts-ci Medium story
private getTestData = async (): Promise<void> => {
try {
this.setState({ error: "" });
const response = await axios.get<Item[]>("/api/items", { headers: session.getAuthHeaders() });
this.setState({ data: response.data });
} catch (error) {
this.setState({ error: "Something went wrong" });
} finally {
this.setState({ isRequesting: false });
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment