[Redux-Saga & Next.js] getServerSideProps에서 dispatch 수행하기 (store.dispatch(END), store.sagaTask.toPromise())
2023. 12. 21. 21:41
개발/Javascript
// SSR export const getServerSideProps = wrapper.getServerSideProps( (store) => async () => { store.dispatch({ type: LOAD_USER_REQUEST, }); store.dispatch({ type: LOAD_POSTS_REQUEST, }); //saga에서 END 액션불러오기 store.dispatch(END); //saga에서 success될때까지 기다려주는 액션 await store.sagaTask.toPromise(); } ); 강의에서 CSR에서 dispatch하던 부분을 SSR로 바꾸는 도중 store.dispatch와 store.sagaTask.toPromise()를 적는 이유가 궁금해서 조금 더 찾아..
[javascript] 로그인 이후 Request failed with status code 401 Unauthorized 인증오류
2023. 11. 28. 20:13
개발/Error note
로그인 이후 게시글 작성을 하려는데 401 unauthorized 오류가 떴다.왜 권한이 없다고 걸렸을까? 문제는 CORS에 있다. 이전에 프론트와 백 포트가 달라서 CORS로 포트허용 해주긴 했으나, 도메인이 다르면 쿠키가 전달이 되지않기 때문에 추가로 credentials 속성도 추가해줘야한다. // 프론트 => 프론트 여러군데에서 쓸 때는 공통 설정 해주면 된다 axios.defaults.withCredentials = true; //공통설정 function addPostAPI(data) { return axios.post( '/post', { content: data }, { withCredentials: true, } ); } // 백 app.use( cors({ origin: 'http://l..
[Javascript] client.js:1 The above error occurred in task removePost Cannot read properties of undefined (reading 'data') RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: 10
2023. 11. 22. 21:50
개발/Error note
게시글을 삭제하는데 개발자 도구 브라우저 콘솔에서 위와같은 에러가 떴다. function* removePost(action) { console.log('removePost::', action); try { const result = yield call(removePostAPI, action.data); yield put({ type: REMOVE_POST_SUCCESS, data: result.data, }); yield put({ type: REMOVE_POST_OF_ME, data: action.data, }); } catch (err) { console.error(err); yield put({ type: REMOVE_POST_FAILURE, data: err.response.data, }); } ..
[JS] Safari에서 new Date 객체 Invalid Date 리턴 받는 경우
2023. 11. 20. 01:29
개발/Error note
원인은 Safari 에서는 new Date 객체에서의 DateType (yyyy-mm-dd)이지원되지 않는 데이터 포맷이었기 때문이다. 따라서 포맷을 yyyy/mm/dd 의 형태로 변경해서 사용해야 한다.function stringToDate(string) { if (!string) return return new Date(string.replace(/[년월일]/g, '').replace(/ /g, ',')) } 아래와 같이 수정 function stringToDate(string) { if (!string) return return new Date(string.replace(/[년월일]/g, '').replace(/ /g, '/')) } 참고: - https://stackoverflow.com/ques..
[RunCat] CPU 사용량을 귀엽게 보여주는 프로그램
2023. 11. 9. 22:14
개발/Install, setting, etc
귀여운 프로그램을 발견했다. CPU의 사용량에따라 달리는 속도가 달라지는 프로그램이다. *(귀엽다) Mac RunCat The cat takes up residence in your Mac's menu bar, and he just keeps running! The cat will run at a speed that depends on the CPU usage on your Mac. You can see how much the current CPU usage is by looking at the running of the cat. How about looking at apps.apple.com 내일 회사가서 설치해야지~ Windows Releases · Kyome22/RunCat_for_windows..