我有一系列需要Axios
按顺序提出的请求。
let {files} = this.state, requestQueue = [];
files.forEach(file => requestQueue.push(makeRequest(file.name)));
requestQueue.reduce((curr, next) => {
return curr.then(next);
}, Promise.resolve()).then((res) => console.log(res));
函数makeRequest如下
import Axios from 'axios';
let axiosCustom = Axios.create({
baseUrl: 'localhost:8080',
headers: {
Accept: 'application/json'
}
});
const makeRequest = (title) => {
return axiosCustom({
url: '/api',
method: 'PUT',
params: {
title
}
});
};
响应只是第一个解决的。我该如何解决?