how to use request and axios in reacdt code example
Example 1: axios vs request
axios.post('http://pokeapi.co/api/v2/pokemon/', { pokemon: 'Pikachu', }) .then((response) => { return response; }) .catch((error) => { console.log(error); });
Example 2: how to use axios get
const req = async () => {
const response = await axios.get('https://dog.ceo/api/breeds/list/all')
console.log(response)
}
req() // Calling this will make a get request and log the response.