import axios from 'axios' import {useEffect, useState} from 'react' const Notification = (props) => { const namesOfCountries = props.countries.map(country => { return
  • {country.name.official}
  • }) if (props.countries.length <= 10 && props.countries.length > 1) { return (
             
            
    ) } else if (props.countries.length > 10) { return

    Too many matches, specify another filter

    } else if (props.countries.length === 1) { // retrieve object pertaining to country const country = props.countries[0] console.log(props.countries[0]) // extract languages from let languages = [] for (let value in country.languages) { languages = languages.concat(
  • {country.languages[value]}
  • ) } return (

    {country.name.official}

    capital {country.capital}

    area {country.area}

    languages:

    {country.flags.alt}
    ) } } const App = () => { const [country, setCountry] = useState('') const [countries, setCountries] = useState([]) const handleChange = (event) => { console.log(event.target.value) setCountry(event.target.value) } useEffect( () => { axios .get('https://restcountries.com/v3.1/all') .then(response => { if(country) { const filtered = response.data.filter(value => value.name.official .includes(country)) setCountries(filtered) console.log(countries, countries.length) } }) //.catch(response => { //return null //}) }, [country, countries] ) return (
    find countries
    ) } export default App;