diff --git a/src/components/Breeds.js b/src/components/Breeds.js index a4416df..d409e7d 100644 --- a/src/components/Breeds.js +++ b/src/components/Breeds.js @@ -2,20 +2,49 @@ import React from "react"; import "./Breeds.css"; class Breeds extends React.Component { + constructor(props) { + super(props); + this.state = { + listOfBreeds: [], + imgSrc: [], + isChanged: false + }; + } + componentDidMount() { + fetch("https://dog.ceo/api/breeds/list/all") + .then((res) => res.json()) + .then((data) => { + this.setState({ + listOfBreeds: Object.keys(data.message) + }); + }); + } + + changeHandler = (event) => { + fetch("https://dog.ceo/api/breed/" + event.target.value + "/images/random") + .then((res) => res.json()) + .then((data) => { + this.setState({ + imgSrc: data.message + }); + }); + }; render() { return (

Select a Breed

- +

+ +

- + + +