A_A*_*A_A 2 http vue.js axios vuejs2
我正在尝试执行两个非并发请求,但是在执行第二个请求之前,我想使用第一个请求中的数据.如何从第一个请求获取数据然后将该数据用于第二个请求?
axios.get('/user/12345').then(response => this.arrayOne = response.data);
axios.get('/user/12345/' + this.arrayOne.name + '/permissions').then(response => this.arrayTwo = response.data);
Run Code Online (Sandbox Code Playgroud)
您可以将第二个axios调用嵌套在第一个调用中.
axios.get('/user/12345').then(response => {
this.arrayOne = response.data
axios.get('/user/12345/' + this.arrayOne.name + '/permissions').then(
response => this.arrayTwo = response.data
);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2734 次 |
| 最近记录: |