{"size": 1892, "ext": "js", "max_stars_repo_path": "lab8/client/src/components/Get/index.js", "max_stars_repo_name": "samanthafarls/DIG4503-Spring2021", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lab8/client/src/components/Get/index.js", "max_issues_repo_name": "samanthafarls/DIG4503-Spring2021", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "lab8/client/src/components/Get/index.js", "max_forks_repo_name": "samanthafarls/DIG4503-Spring2021", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.5625, "max_line_length": 98, "alphanum_fraction": 0.4815010571}
import Axios from 'axios';
import { useState } from 'react';

function Get(){
    //first route
    const [addPeople, setAddPeople] = useState("");
    const [searchPeople, setSearchPeople] = useState("");
    const [addResults, setAddResults] = useState([]);
    //second route
    const [findLetter, setFindLetter] = useState("");
    const [searchLetter, setSearchLetter] = useState("");
    const [letterResults, setLetterResults] = useState([]);
  
    //first route
    function Add() {
        Axios.get("http://localhost:45030/people/" + addPeople )
        .then(response => {
          console.log(response.data);
          setAddResults(response.data.addPeople);
        })
        .catch(error => {
          console.log("Error" + error);
        })
  
        
          
    }
        //second route
    function Search() {
        Axios.get("http://localhost:45030/search/" + findLetter)
        .then(response => {
          console.log(response.data);
          setLetterResults(response.data.search);
        })
        .catch(error => {
          console.log("Error" + error);
        })
  
        
          
    }
  
        return (
            <div>
                <input type= "text" onChange={(event) => setAddPeople(event.target.value)} />
                    <button onClick= {() => Add()}>Click to find a Person!</button>
                    <p>{addPeople}</p>
            
                   

                    <input type= "text" onChange={(event) => setFindLetter(event.target.value)} />
                    <button onClick= {() => Search()}>Click to search for a Letter!</button>
                    {
                        letterResults.map((value, index) => {
                           return <p key = {index}>{value}</p>
                        })
  
                        
                    }
            </div>
        )
}

export default Get;