-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
const idCheckHandler = () => {
const email = {
"email": userEmail,
};
axios
.post("/api/member/search/id", email)
.then((response) => {
console.log(response.data);
const responseData = response.data;
alert("아이디를 찾았습니다.")
})
.then((result) => {
console.log(result);
})
.catch((error) => {
console.log(error)
alert("입력하신 이메일로 가입한 아이디가 없습니다.")
})
}
아이디 찾기 버튼을 눌렀을 때 console에 찍히지 않고 웹에 바로 출력을 하고 싶었으나 웹에 출력이 되지 않았습니다.
그래서 생각을 해보다 useState를 활용하면 결과 값을 출력할 수 있을 거라 생각하여 responseData를 useState에 담아 출력하였습니다.
const [searchResult, setSearchResult] = useState('');
/...생략.../
axios
.post("/api/member/search/id", email)
.then((response) => {
console.log(response.data);
const responseData = response.data;
setSearchResult(responseData)
alert("아이디를 찾았습니다.")
중간에 set에 담아 출력해준 출력해주었더니 아이디 찾기 결과 값이 웹이 출력되었습니다.

DB안에 있는 Email을 통해 아이디를 찾는 방식으로 코드를 작성해보았습니다.
위와 같이 Email을 입력하였을 때 '1234'라는 아이디를 찾을 수 있었습니다.
Metadata
Metadata
Assignees
Labels
No labels