
createAsyncThunk
·
🎨 프론트엔드 공부/기타
📍Async Thunk Function - 전체 유저 리스트를 fetch하는 fetchUsers 흐름 📍createAsyncThunk - 코드 예시 interface MyData { // ... } const fetchUserById = createAsyncThunk( 'users/fetchById', // 액션 크리에이터 함수의 매개변수에는 typing 필요 async (userId: number) => { const response = await fetch(`https://reqres.in/api/users/${userId}`) // Inferred return type: Promise return (await response.json()) as MyData } ) // the parameter of..