我有2接口,怎么把第一个接口的返回的值,作为第二个接口的参数
@jayzou
promise是这样用的
axios.get('xxx')
.then((data) => {
return axios.get('xx', data.data)
})
.then((data) => {
})
axios.post('http://139.196.140.118:8080/',
{
'Comment': {
},
'User': {
'id@': 'Comment/userId' // User.id = Comment.userId
}
})
.then(res => {
console.log(res.data)
})
.catch(err => {
console.log(err);
})
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.3k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
谢邀。
你的这个问题,可以用.then的promise方式来写。
另外,推荐一种es7的
async/await
的异步方式,更接近与同步的写法具体写法和原理,请参照