강의

멘토링

커뮤니티

Inflearn Community Q&A

roider23164240's profile image
roider23164240

asked

Slack Clone Coding [Real-time Chat with React]

Making a Modal

api/workspaces POST요청시 500에러가 뜹니다.

Resolved

Written on

·

911

·

Edited

0

 const onCreateWorkspace = useCallback(
    (e: any) => {
      e.preventDefault();
      if (!newWorkspace || !newWorkspace.trim()) return; // trim : 앞 뒤 공백제거
      if (!newUrl || !newUrl.trim()) return;
      axios
        .post(
          'http://localhost:3095/api/workspaces',
          {
            Workspace: newWorkspace,
            url: newUrl,
          }, { 
            withCredentials: true 
          },
        )
        .then(() => {
          mutate(userData, true);
          setShowCreateWorkspaceModal(false);
          setNewWorkspace('');
          setNewUrl('');
        })
        .catch((error) => {
          console.dir(error);
          toast.error(error.response?.data, { position: 'bottom-center' });
        });
    },
    [newWorkspace, newUrl],
  );

뭐가 문제인건가요?

react웹팩typescriptsocket.iobabel클론코딩

Answer 2

0

안녕하세요 ! 혹시 저도 같은 에러가 나온 상태여서 혹시 어디서 대소문자가 오타였는지 알 수 있을까요?

zerocho님의 프로필 이미지
zerocho
Instructor

Workspace.name cannot be null 에러라면 서버로 name 데이터가 안 간 겁니다. req.body 체크해보세요.

빠른 답변 감사드립니다. 해결 되었습니다 !

0

zerocho님의 프로필 이미지
zerocho
Instructor

서버를 실행한 터미널에 에러 메시지 있을 겁니다.

roider2316님의 프로필 이미지
roider2316
Questioner

터미널에 SequelizeValidationError: notNull Violation: Workspace.name cannot be null 에러가 떴었고 잘 찾아보니깐 대소문자 문제였네요. 감사합니다.

roider23164240's profile image
roider23164240

asked

Ask a question