When I have Two APIs and one for cats data and one for cats image, how can I populate images and data from two APIs in one component using hooks through Axios call?
CatsList.js
import React, {useState, useEffect} from 'react'
import {baseUrl} from './services/mainApi';
import axios from 'axios';
export default function CatsList() {
const [data, setData] = useState([]);
useEffect(() => {
const fetchData = async () => {
const result = await axios(
`${baseUrl}breeds`,
);
setData(result.data);
};
fetchData();
}, []);
return (
<ul className="row">
{data.map(item => (
<li className="col-md-3 list-item" key={item.id}>
<a href={item.wikipedia_url}>
<h2>{item.name}</h2>
<p>{item.origin}</p>
<p>{item.description}</p>
</a>
</li>
))}
</ul>
);
}
mainApi.js
import axios from 'axios';
export const baseUrl = 'https://api.thecatapi.com/v1/'
export const catsImage = `${baseUrl}/images/search?breed_id=abys`