順番に行う必要がある一連のリクエストがあります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
}
});
};
応答は、最初に解決されたものです。これを修正するにはどうすればよいですか?