Please review the axios code

mail@pastecode.io avatar
unknown
javascript
2 years ago
723 B
7
Indexable
Never
import React, { useState } from 'react';
import './App.css';
import Axios from "axios";

function App() {
  const[pokemonName, setPokemonName] = useState("");
  const searchPokemon = () => {
    Axios.get(`https://pokeapi.co/api/v2/pokemon/${pokemonName}`).
    then((response) => {
      console.log(response);
    })
  }
  return(
    <div className = "App">
      <div className = "TitleSection">
        <h1>Pokemon Stats</h1>
        <input 
          type = "text" 
          onChange={(event)=> {
          setPokemonName(event.target.value);
        }}
       />
        <button onClick={searchPokemon}>Search Pokemon</button>
      </div>
    </div> 
  
  );
}

export default App;