📜  功能组件中的 axios - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:19.293000             🧑  作者: Mango

代码示例1
import { useEffect } from 'react';

const Translator = () => {
    const [languages, setLanguages] = useState([]);
    useEffect(() => {
      getLanguages().then(data => {
         setLanguages(data.languages)
      });

      console.log(languages);
    }, []);
    
  
  return (
    
{ languages.length > 0 && ( languages.map( lang =>

{lang.language}

) ) }
); };