Compare commits

..

No commits in common. "578f6e8bd43b994c7a5970632df2773d625d1454" and "a98fb2560f24acc36db620ceac21a09712ee725b" have entirely different histories.

View File

@ -3,11 +3,8 @@ import { useMessage } from '@/hooks/useMessage'
import { useSwal } from '@/hooks/useSwal'
import { sessionStore } from '@/store/commonAtom'
import { getQueryString } from '@/util/common-utils'
import { atom, useRecoilState, useRecoilValue } from 'recoil'
import { useRecoilValue } from 'recoil'
// API 요청을 저장할 모듈 레벨 변수 (Hook 외부)
let roofMaterialPromise = null;
/**
* 마스터 컨트롤러
* @returns
@ -23,23 +20,10 @@ export function useMasterController() {
* @returns
*/
const getRoofMaterialList = async () => {
// 1. 이미 진행 중이거나 완료된 Promise가 있으면 그것을 반환
if (roofMaterialPromise) {
return roofMaterialPromise;
}
// 2. 처음 호출될 때 Promise를 생성하여 변수에 할당
roofMaterialPromise = get({ url: '/api/v1/master/getRoofMaterialList' })
.then((res) => {
return res;
})
.catch((error) => {
// 에러 발생 시 다음 호출을 위해 초기화
roofMaterialPromise = null;
throw error;
});
return roofMaterialPromise;
return await get({ url: '/api/v1/master/getRoofMaterialList' }).then((res) => {
// console.log('🚀🚀 ~ getRoofMaterialList ~ res:', res)
return res
})
}
/**