import * as React from "react"; import { getTasks } from "./habiticaAPI" const username = "" const credentials = "" class App extends React.Component { constructor(props: any) { super(props) this.state = { isLoaded: false, tasks: "" } } componentDidMount() { getTasks(username, credentials) .then(res => res.json()) .then( result => { console.log(result.data) this.setState({ isLoaded: true, tasks: result.data }) }, (error) => { this.setState({ isLoaded: true, error }) } ) } render(){ const { error, isLoaded, tasks } = this.state; if (error) { return
Error: {error.message}
; } else if (!isLoaded) { return
Loading...
; } else { const listItems = tasks.map((tasks: any) =>
  • {tasks.text}
  • ); return (
      {listItems}
    ); } } } export default App