๐Ÿ“ Day 83(57)์ผ์ฐจ WE_MOTIVATION_DIARY

10658 ๋‹จ์–ด MOTIVATION_DIARYMOTIVATION_DIARY

- ํ”„๋กœ์ ํŠธ ์ง„ํ–‰ํ˜„ํ™ฉ

  • ๋ฐฑ์—”๋“œ + ํ”„๋ก ํŠธ ๋ถ™์—ฌ๋ณด๊ธฐ
  • ๋ถ™์—ฌ๋ณธ ๊ฒฐ๊ณผ๋ฌผ์„ ํ† ๋Œ€๋กœ ํ”„๋ก ํŠธ ๋ฐ ๋ฒก์—”๋“œ๋ฅผ ์ˆ˜์ •

- TODAY I LEARN ERROR ๐Ÿฆ 

  • ํ‚ค์—๋Ÿฌ์™€ ํ‚ค์˜ ๊ฐ’์ด ๋น„์–ด์žˆ๋Š” ๊ฒฝ์šฐ๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด
    ์กฐ๊ฑด๋ฌธ์„ ์จ์„œ ์—๋Ÿฌ๋ฅผ ๋ฐœ์ƒํ•˜๊ธฐ ์‰ฌ์šด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜์˜€์Œ

- HOW TO FIX MY ERROR ๐Ÿ’Š

  • ERROR๋ฅผ ํ•ด๊ฒฐํ•œ ํ‚ค์—๋Ÿฌ์™€ ํ‚ค์˜๊ฐ’์ด ๋น„์–ด์ ธ์žˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•ด์ฃผ๋Š” ํ•จ์ˆ˜๋ฅผ ๋ชจ๋“ˆํ™”์—ฌ ์šด์˜๐Ÿ”‘
  • checkvalidation.js ๋ชจ๋“ˆ
<script>
// ํ‚ค์˜ ๊ฐ’์ด ๋น„์–ด์ ธ์žˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜
export const checkEmptyKeyOfValue = (userInfo) => {
  const userInputData = Object.entries(userInfo);
  const userInputInfo = new Map(userInputData);
  for (let data of userInputInfo) {
    if (data[1] === '') return data[0];
  }
};
// ํ‚ค๊ฐ€ ๋น„์—ฌ์ ธ์žˆ๋Š”์ง€๋ฅผ ํ™•์ธํ•˜๋Š” ํ•จ์ˆ˜
export const checkEmptyKey = (KeyList, userInfo) => {
  const keyArr = [];
  let emptyKeyArr = [];
  const userInputData = Object.entries(userInfo);
  const userInputInfo = new Map(userInputData);
  for (let key of userInputInfo.keys()) {
    if (KeyList.includes(key)) {
      keyArr.push(key);
      const InputKeyAndListArr = keyArr.concat(KeyList);
      const emptyKey = InputKeyAndListArr.filter((e) => !keyArr.includes(e));
      emptyKeyArr = [...emptyKey];
    }
  }
  return emptyKeyArr;
};
</script>
  • signInController.js์—์„œ ์—๋Ÿฌ ์บ์น˜
<script>
// ๋น„์–ด์ ธ์žˆ๋Š” ํ‚ค์˜ ๊ธธ์ด๊ฐ€ 0์ด ์•„๋‹ˆ๋ผ๋ฉด, ํ•˜๋‚˜๋ผ๋„ ๋น„์–ด์ ธ์žˆ๋‹ค๋ฉด
  if (emptyKey.length !== 0) {
    next(new AppError.keyError(`${emptyKey} ํ‚ค๊ฐ€ ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค`));
    return;
  }
  const emptyKeyOfValue = checkEmptyKeyOfValue(userInfo);
 // ๋น„์–ด์ ธ์žˆ๋Š” ํ‚ค์˜ ๊ฐ’์ด ์กด์žฌํ•œ๋‹ค๋ฉด 
 if (emptyKeyOfValue) {
    next(
      new AppError.valueOfKeyError(`ํ‚ค์˜ ${emptyKeyOfValue} ๊ฐ’์ด ๋น„์–ด์žˆ์Šต๋‹ˆ๋‹ค`)
    );
    return;
  }
</script>

- ๋ชจ๋ฅด๋Š” ์ 

  • ํ‚ค์™€ ํ‚ค์˜ ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ๋กœ์ง์„ ๋งŒ๋“ค๊ธฐ์œ„ํ•ด์„œ map๊ณผ sep ๊ฐœ๋…์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ด„

- ๋ฐฐ์šด์ 

  • new Map()๋ฅผ ์ƒ์„ฑํ•˜๋ฉด keys(), values(), entry ๋“ฑ ๋‹ค์–‘ํ•˜๊ฒŒ ํ‚ค์™€ ํ‚ค์˜ ๊ฐ’ ์Œ์„ ๋ฝ‘์•„๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋ฉ”์„œ๋“œ๋“ค์ด ์กด์žฌํ•œ๋‹ค๋Š” ๊ฒƒ

- ์ž˜ํ•œ ์ ๊ณผ ๊ฐœ์„ ํ•  ์ 

  • ๋Šฆ๊ฒŒ๋ผ๋„ ํšŒ๊ณ ๋ก์„ ๋๊นŒ์ง€ ์ ์€ ์ ~
  • ๋„ˆ๋ฌด ํšŒ๊ณ ๋ก์„ ๋Šฆ๊ฒŒ ์˜ฌ๋ฆฐ์ ~

- ๋ชฉํ‘œ์™€ ๋งˆ๊ฐ๊ธฐํ•œ: 2021-10-14

  1. ๋ฒก์—”๋“œ ํ”„๋ก ํŠธ ํ•ฉ์ณ์„œ ๊ธฐ๋Šฅ๊ตฌํ˜„์€ ๋งˆ๋ฌด๋ฆฌ์ง“๊ธฐ
  2. ๋ฐฑ์—”๋“œ ๋ฆฌํŒฉํ† ๋ง ์ง„ํ–‰ํ•˜๊ธฐ

์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ