axios in react functional component code example
Example: axios in functional component
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>
);
};