Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在react中是如何发送ajax请求的 #41

Open
yinyinnnn opened this issue Jun 8, 2021 · 2 comments
Open

在react中是如何发送ajax请求的 #41

yinyinnnn opened this issue Jun 8, 2021 · 2 comments

Comments

@yinyinnnn
Copy link

No description provided.

@guowei55555
Copy link

第一步,先安装axios

npm install -save axios

第二步 ,在所需文件引入axios

import axios from 'axios';

第三步,使用axios请求后台数据

 componentDidMount() {
    this.getTodos()
  }
 getTodos = async () => {
     axios.get('/user', { 
         params: {  
               id: 12345,
              name: user
         }
     })
    .then(function (res) {
       console.log(res);
    })
   .catch(function (err) {
    console.log(err);
   });
  }

@guowei55555
Copy link

@Dogtiti Dogtiti removed the Cbayel label May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants