Axios em componente funcional
import { useEffect } from 'react';
const Translator = () => {
const [languages, setLanguages] = useState([]);
useEffect(() => {
getLanguages().then(data => {
setLanguages(data.languages)
});
console.log(languages);
}, []);
return (
<header className="translator__header">
{
languages.length > 0 && (
languages.map( lang => <h1>{lang.language}</h1>)
)
}
</header>
);
};
Dark Donkey