이렇게 액션 안에 meta 값을 response로 넣어 주면 나중에 HTTP 헤더 및 상태 코드를 쉽게 조회할 수 있습니다.

    posts 리덕스 모듈을 열어서 다음과 같이 수정해 주세요.

    modules/posts.js

    (...)
    
    const initialState = {
      posts: null,
      error: null,
      lastPage: 1,
    };
    
    const posts = handleActions(
      {
        [LIST_POSTS_SUCCESS]: (state, { payload: posts, meta: response }) => ({
          ...state,
          posts,
          lastPage: parseInt(response.headers['last-page'], 10), // 문자열을 숫자로 변환
        }),
        [LIST_POSTS_FAILURE]: (state, { payload: error }) => ({
          ...state,
          error,
        }),
      },
      initialState,
    );
    
    export default posts;

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.