Promise
-
Promise 동시에 여러번 호출Language/React 2024. 10. 15. 13:02
Promise 여러개 한번에 호출해서 받으려고 할때 헷갈려서 정리해두자.소스const promise1 = request.get('/v1/api1', param);const promise2 = request.get('/v1/api2');const responses = await Promise.all([promise1, promise2]);{ const response = responses[0]; for (let key in response.items) { ... }}{ const response = responses[1]; for (let code of response.items) { ... }}