useEffect(() => {
new Promise(resolve => {
setTimeout(() => {
resolve();
/* 신규 로트번호 생성을 위한 다음 auto_increment 가져오기 */
axios
.get("http://localhost:8080/api/item/autoId")
.then(response => {
var output = response && response.data;
const newLote = lote;
newLote.lote = nowDate + "-" + output;
setLote(newLote);
})
.catch(response => {
console.log(response);
});
}, 600);
}),
new Promise(resolve => {
setTimeout(() => {
resolve();
//재고조회 (로트번호 검색기능)
axios
.get("http://localhost:8080/api/item/1")
.then(response => {
var output = response && response.data;
const newLookup = Object.assign({}, lookup);
for (var i = 0; i < output.list.length; i++) {
var value = output.list[i].lote_id;
newLookup.lookup[value] = value;
}
newLookup.lookup[lote.lote] = lote.lote;
setLookup(newLookup);
console.log(lookup.lookup);
const newState = Object.assign({}, state);
newState.columns[1].lookup = lookup.lookup;
setState(newState);
})
.catch(response => {
console.log(response);
});
}, 600);
}),
new Promise(resolve => {
setTimeout(() => {
resolve();
/* 출고 이력 불러오기 */
axios
.get("http://localhost:8080/api/shipping/history/1")
.then(response => {
var output = response && response.data;
const newState = Object.assign({}, state);
newState.data = output.list;
setState(newState);
})
.catch(response => {
console.log(response);
});
}, 600);
});
}, []);
The useEffect () function in my function components is shown below.
Below is a total of three asynchronous communication.
The problem is that those asynchronous communications don't go through the same order each time.
How do you proceed with asynchronous communication as shown in the code?