{"size": 1076, "ext": "js", "max_stars_repo_path": "lab9/components/idSearch/index.js", "max_stars_repo_name": "loobree16/DIG4503", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab9/components/idSearch/index.js", "max_issues_repo_name": "loobree16/DIG4503", "max_issues_repo_issues_event_min_datetime": "2021-03-10T11:32:12.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-26T06:48:27.000Z", "max_forks_repo_path": "lab9/components/idSearch/index.js", "max_forks_repo_name": "loobree16/DIG4503", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 7, "max_forks_count": null, "avg_line_length": 22.8936170213, "max_line_length": 70, "alphanum_fraction": 0.5250929368}


class IdSearch extends React.Component {

  
    getId(event) {
      event.preventDefault();
    
      let input = document.getElementById("idInput").value;
  
    
      fetch("/api/pokemon/id/" + input)
      .then((res) => { 
        return res.json()
       })
      .then((result) => {
        
        let resultId = document.querySelector("#reportingId");
        let resultName = document.querySelector("#reportingName");
        let resultType = document.querySelector("#reportingType");
        if(result.error) {
          
          resultId.innerHTML = "There was an error, try again.";
        } else {
          
          resultName.innerHTML = "Name: " + result.name;
          resultId.innerHTML = "ID: " + result.id;
          resultType.innerHTML = "Type: " + result.typeList;
        }
  
      });
    }

  
  
    render() {
      return (
         <form>
          <input type="text" id="idInput" placeholder="enter an ID" />
          <button onClick={this.getId}>SUBMIT</button>
        </form>
        
      );
    }
}

export default IdSearch;