-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature/#32 #39
Conversation
<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"> |
There was a problem hiding this comment.
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이 인식이 안되네요
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
로그인 할 때 api가 이 주소가 맞나요?
네트워크 탭을 열어서 확인해보니 500 에러가 자꾸 떠서
주소 문제인지 코드를 잘못 입력한건지 잘 모르겠습니다.
There was a problem hiding this comment.
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 함수 인자를 잘못 넘겼거나요
front/src/remotes/index.jsx
Outdated
const postUsersLogin = (user) => conduitAxios.post(`/users/login`); | ||
// postUsersLogin(user).then((res) => { | ||
// console.log(res); | ||
// } |
There was a problem hiding this comment.
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, ... } }
이슈 넘버
[#32] 4-6. axios로 api 받아오기
요약
signin, signup 변경
변경 내용 설명