소개
게시글
질문&답변
2022.01.25
ADD_POST_TO_ME 질문있습니다.
(사진) back/routes/user.js 늦은 시간 죄송하고.. 답변 감사합니다. include 문제였습니다..
- 0
- 2
- 130
질문&답변
2022.01.20
새로고침 시 hydrate 상태 초기화 문제 질문 있습니다.
2는 뭐죠..? 2가 없는데... (사진) (사진) (사진) (사진)
- 0
- 7
- 463
질문&답변
2022.01.20
새로고침 시 hydrate 상태 초기화 문제 질문 있습니다.
(사진) 1은 비어있고 2는 없습니다;;
- 0
- 7
- 463
질문&답변
2022.01.20
새로고침 시 hydrate 상태 초기화 문제 질문 있습니다.
(사진) 처음에는 request 요청이 가면 success 까지 잘 받아오는데 새로고침을 하면 request만 가고 이후 success에 대한 응답이 없습니다. (사진) req.header에 cookie는 잘 담겨 있고 요청에 따라 cookie 변수에도 잘 담겨있는걸 확인했습니다. (사진) 그런데 이후 request 만 가고 success에 대한 응답이 없고 null 값입니다. (사진) (사진) redux-saga에서 요청하고 sucess까지 받아오는데 기다리지를 못하는 것 같습니다. 그런데 코드에는 아무리 봐도 이상이 없습니다... 구글링을 통해 다른 코드를 참고하여 살펴봐도 여전히 문제점을 발견하지 못하고 있습니다ㅠㅠ import { END } from 'redux-saga' ; import { wrapper } from '../store/configureStore' ; import axios from 'axios' ; . . . export const getServerSideProps = wrapper . getServerSideProps (( store ) => async ({ req , res , ... ets }) => { console . log ( 'getServerSideProps req.headers: ' , req . headers ); const cookie = req ? req . headers . cookie : '' ; console . log ( 'cookie: ' , cookie ); axios . defaults . headers . Cookie = '' ; // 서버에서 다른 사람과 cookie가 공유되는 문제를 방지하고자 초기화를 해준다. if ( req && cookie ) { axios . defaults . headers . Cookie = cookie ; // 서버에서 요청일때랑 cookie가 있으면 설정한 cookie를 넣어준다. console . log ( 'axios.defaults.headers.Cookie: ' , axios . defaults . headers . Cookie ); } store . dispatch ({ type : LOAD_MY_INFO_REQUEST , }); store . dispatch ( END ); await store . sagaTask . toPromise (); // reducers/index.js import { combineReducers } from 'redux' ; // 여러 리듀서들을 하나로 합쳐준다. import { HYDRATE } from 'next-redux-wrapper' ; import user from './user' ; import post from './post' ; // HYDRATE가 동작할 때 initStates들이 index user post 자체를 덮어씌울 수 있도록 구조를 작성 const rootReducer = ( state , action ) => { switch ( action . type ) { case HYDRATE : console . log ( 'HYDRATE' , action ); return action . payload ; default : { const combineReducer = combineReducers ({ user , post , }); return combineReducer ( state , action ); } } }; export default rootReducer ; 참고: https://github.com/ko7452/e-Library 제 github 입니다..
- 0
- 7
- 463
질문&답변
2022.01.20
새로고침 시 hydrate 상태 초기화 문제 질문 있습니다.
감사합니다!!
- 0
- 7
- 463