async componentDidMount()

in src/Search.js [132:170]


  async componentDidMount() {
    this.setState({ loading: true })
    try {
      var apiData = await API.graphql(graphqlOperation(ListReports))
      const { data: { listReports } } = apiData
      const items = listReports
      this.setState({ items, loading: false })

      apiData = await API.graphql(graphqlOperation(ListPositiveICD10CMs))
      const { data: { getAllPositiveICD10CMs } } = apiData
      const posICD10s = getAllPositiveICD10CMs.map(
            (obj, ind) => {
                return {
                    x : ind,
                    y : obj.doc_count,
                    label: shortenLabel(obj.key)
                }
            }
        );
      this.setState({ posICD10s, loading: false })

      apiData = await API.graphql(graphqlOperation(ListNegativeICD10CMs))
      const { data: { getAllNegativeICD10CMs } } = apiData
      const negICD10s = getAllNegativeICD10CMs.map(
            (obj, ind) => {
                return {
                    x : ind,
                    y : obj.doc_count,
                    label: shortenLabel(obj.key)
                }
            }
        );
      this.setState({ negICD10s, loading: false })

      // console.log(this.state)
    } catch (err) {
      console.log('error fetching data: ', err)
    }
  }