我需要进行n个api调用,其中n是从第一个api调用的响应中获得的,并在所有后续调用中用作参数。代码中我缺少什么?
var axios = require('axios');
axios.get('url', {
headers: {'Accept': 'application/json'},
params: {
param1 : '1',
param2 : '2',
param3 : '3',
param4 : '4'
}
})
.then((response) => {
console.log(response.data);
for(var page_number = 1; page_number <= response.data; page_number++){
axios.get('url', {
headers: {'Accept': 'application/json'},
params: {
param1 : '1',
param2 : '2',
param3 : '3',
param4 : page_number
}
})
.then((response) => {
console.log(response.data);
});
.catch(function (error) {
console.log(error);
});
});
}
.catch(function (error) {
console.log(error);
});
Thanks for your help!