codestates / codestates/underTheSea

[✍️ Dev Log] 송다영 / 2022-01-19


Open
#137 0 comments 0 reactions 1 assignee Claimed by @songdayoung1 View on GitHub
Bare Minimum Client Sprint 3
Dominant language
JavaScript
Stars
0
Forks
5
PR merge metrics
No merged PRs in 30d

Description

### 오늘은 어떻게 프로젝트에 기여했나요?

- Logout 요청과 그에 따른 헤더의 상태 변경

### 오늘의 프로젝트에서 힘든 점은 무엇인가요?

- 서버에 요청을 보내기 위해서 Logout을 Post로 보냈는데 헤더쓰의 Authorization의 토큰이 어디서 전달되었는지 확인하는 과정이 어려웠다.
- 콘솔을 찍어서 확인해 보니 req.headers로 넘겨받아서 url 다음에 빈객체를 넘겨주고 그 다음에 토큰을 전달하니
req.body로 잘 전달하는 것을 확인할 수 있었다.

```js

//Header.js에서 Logout 구현
// 삼항 연산자를 통해 Header의 상태를 변경

const handleLogout = () => {
axios
.post(
`http://localhost:80/user/logout`,
{},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
{
withCredentials: true,
}
)
.then((res) => {
localStorage.setItem("accessToken", "");
dispatch(logoutAction);
console.log(res);
})
.catch((err) => {
console.log(err);
});
};

// return문의 상태변경

{isLogin ? (
<>

관리


마이페이지

{/* 로그아웃 */}

) : (
<>
dispatch(loginModalOnAction)}>로그인
dispatch(signupModalOnAction)}>
회원가입


)}
{!isLogin ? (
<>
) : (
<>
로그아웃

)}

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.