개발일지

개발일지 73일차

index.ys 2023. 6. 18. 02:07

내가 작성한 게시글, 푸박스 ,북마크 배열로 넘기기

  • db에서 조회한 게시글, 푸박스 ,북마크 데이터를 가져오기
  • 가져온 각데이터의 길이를 배열에 넣음
  • 인포데이터와 각 게시글들의 갯수를 담아서 리턴해줌
 getMyInfo = async (req, res) => {
        const { userId } = res.locals.user;
        const getMyInfoData = await this.mypagesService.getMyInfo(userId);
        const getMyPooData = await this.mypagesService.getMyPoo(userId)
        const getMyBookmarkData = await this.mypagesService.getMyBookmark(userId)
        const getMyPostData = await this.mypagesService.getMyPost(userId)
        const mypageContent = []
        mypageContent.push(getMyPooData.length)
        mypageContent.push(getMyPostData.length)
        mypageContent.push(getMyBookmarkData.length)
        return res.status(201).json({ getMyInfoData, mypageContent });
    };

에러케이스 수정, 리팩토링

  • 로그인시 발생하는 에러 status 코드는 전부 403으로 수정함 => 서버에서 전달한 에러코드를 가지고 프론트엔드에서 로그인시 발생한 에러를 공통에러 핸들러로 처리하기 위함
  • 예외처리 케이스는 400으로 통일하고 그외 입력값의 오류에 대한 에러처리는 400 status를 공통으로 적용하여 코드의 일관성 부여