下载axios
yarn add axios
import React, { Component } from 'react'import axios from 'axios'export default class index extends Component {componentDidMount(){//get请求axios({url:'https://httpbin.org/get',params:{name:'why',age:18}}).then(res=>console.log(res)).catch(err=>console.error(err))axios.get('https://httpbin.org/get',{params:{name:'apiwhy',age:28}}).then(res=>console.log(res)).catch(err=>console.error(err))//post请求axios({url:'https://httpbin.org/post',data:{name:'kobe',age:18},method:'post'}).then(res=>console.log(res)).catch(err=>console.error(err))axios.post("https://httpbin.org/post",{name:'labalon',age:48}).then(res=>console.log(res)).catch(err=>console.error(err))}render() {return (<div></div>)}}
