Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#32 #39

Merged
merged 7 commits into from
Sep 8, 2022
Merged

Feature/#32 #39

merged 7 commits into from
Sep 8, 2022

Conversation

00kang
Copy link
Collaborator

@00kang 00kang commented Sep 7, 2022

이슈 넘버

[#32] 4-6. axios로 api 받아오기

요약

signin, signup 변경

변경 내용 설명

@00kang 00kang marked this pull request as draft September 7, 2022 10:38
@00kang 00kang marked this pull request as ready for review September 7, 2022 10:38
@00kang 00kang marked this pull request as draft September 7, 2022 10:39
@00kang 00kang requested review from gomjellie and thejsw September 7, 2022 10:39
Comment on lines +30 to +42
<form
onSubmit={(e) => {
e.preventDefault();

postUsers({ username, email, password }).then((res) => {
if (res.data.user) {
setIsLoggedIn(true);
localStorage.setItem('token', res.data.user.token);
}
});
}}
>
<fieldset className="form-group">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onSubmit 함수를 만들었으면, 밑에 있는 Button 태그에서 onClick={onSubmit}으로 설정해줘야 하나요? onClick={onSubmit}으로 하면, onSubmit이 인식이 안되네요

Copy link
Member

@gomjellie gomjellie Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thejsw
음... button attribute 중에 type 이라는 놈이 있습니다.

form안에 있는 버튼에 type="submit" 을 이용하게 되면 알아서 submit 동작이 실행됩니다

onClick={onSubmit} 했을때, form의 onSubmit이 인식되지 않는 이유는 preventDefault를 넣어줬기 때문인것같네요.

  • preventDefault와 stopPropagation 은 무엇인지, 이벤트 버블링이란 무엇인지 한번 조사해보세요

baseURL:
// 'https://api.realworld.io/api-docs/#/User%20and%20Authentication/Login',
'https://api.realworld.io/api-docs/',
baseURL: 'https://api.realworld.io/api',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로그인 할 때 api가 이 주소가 맞나요?
네트워크 탭을 열어서 확인해보니 500 에러가 자꾸 떠서
주소 문제인지 코드를 잘못 입력한건지 잘 모르겠습니다.

Copy link
Member

@gomjellie gomjellie Sep 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thejsw https://api.realworld.io/api 맞습니다.

혹시 post, put, get 같은 http 메소드를 잘못쓴게 아닐지 의심되네요. 아니면 axios 함수 인자를 잘못 넘겼거나요

Comment on lines 71 to 74
const postUsersLogin = (user) => conduitAxios.post(`/users/login`);
// postUsersLogin(user).then((res) => {
// console.log(res);
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thejsw post할때 user정보를 넣어주셔야합니다. 500번이 정보가 없어서 뜨는것같아요

대충 아래처럼 써야했던걸로 기억하네요

conduitAxios.post(`/users/login`, { data: { username: user.username, ... } }

@00kang 00kang marked this pull request as ready for review September 8, 2022 13:24
@00kang 00kang merged commit db0780a into main Sep 8, 2022
@thejsw thejsw deleted the feature/#32 branch September 8, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants