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

투드리스트 조영은 뼈대 완성 #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Contingency1
Copy link
Contributor

앙기모링

Copy link
Collaborator

Choose a reason for hiding this comment

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

어떤 함수는 단순히 html,css를 조작하기 위한 함수인데, 어떤 부분은 fetch요청을 통해서 백엔드단과 api통신을 하는 부분입니다.
하나의js파일에서 여러개의 동작을 나중에 본인이 볼 때나, 다른 개발자가 볼 때 혼동을 줄 수 있습니다.
파일을 여러개로 쪼개서 사용하면 이러한 혼동을 줄일 수 있습니다.
importexport 사용하심 될 듯 하네요.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

옙옙

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ㅠㅠ

class UserStorage {
static async getDescription() {
return new Promise((resolve, reject) => {
const query = "SELECT * FROM tdList";
Copy link
Collaborator

Choose a reason for hiding this comment

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

보통 db 테이블 명도 snake_case로 사용합니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

테이블 명 확인했습니다이!!!!

const query = "SELECT * FROM tdList";
db.query(query, (err, data) => {
if (err) {
reject(`${err}`);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
reject(`${err}`);
reject(err);

그냥 이렇게 해도 될 것 같아요

Copy link
Contributor Author

Choose a reason for hiding this comment

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

확인했습니다. 어떤 의미인지 알았어용.

Comment on lines 12 to 16
} else {
// console.log("UserStorage.js의 동작");
// console.log(data);
resolve(data);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
} else {
// console.log("UserStorage.js의 동작");
// console.log(data);
resolve(data);
}
}
// console.log("UserStorage.js의 동작");
// console.log(data);
resolve(data);

Promise는 어차피 reject 아니면 resolve가 호출되기 때문에 else가 없어도 될 것 같습니다.
밑에서 모든 코드 또한 마찬가지 입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

알겠습니다!!


static async appendDescription(description) {
return new Promise((resolve, reject) => {
const query = "INSERT INTO tdList(id, description) VALUES(?, ?);";
Copy link
Collaborator

Choose a reason for hiding this comment

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

테이블의 pk키를 auto_increment로 설정했다면 따로 프론트에서 id값을 받지 않아도 자동으로 id를 +1씩 증가된 값으로 생성해줍니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

알겠습니다!!

}

async updateDescription(data) {
let key = await UserStorage.updateDescription(data);
Copy link
Collaborator

Choose a reason for hiding this comment

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

수정하고자 하는 데이터의 id값과 수정할 내용을 description으로 받는 것으로 보이는데
만약 id값이 number가 아닌 문자열로 들어온다면 에러가 발생하겠죠?
시간이 남으면 그에 대한 처리를 해보면 좋을 것 같습니다.
이는 백엔드 코드에서 처리해야할 문제입니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

고치겠습니다!!

// console.log(user.body);
const response = await user.appendDescription(user.body);

return res.json(response);
Copy link
Collaborator

Choose a reason for hiding this comment

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

express로 개발해본지가 오래 돼서 확신은 못하겠는데
res.status(201).json(response);
이런 식으로 Http Status코드를 직접 지정해주지 않으면 200번 코드로 response가 갈 것 같아요

Copy link
Collaborator

Choose a reason for hiding this comment

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

https://www.webfx.com/web-development/glossary/http-status-codes/
status code 관련해서 참조 링크입니다

Copy link
Contributor Author

Choose a reason for hiding this comment

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

참조하겠습니다

Comment on lines +15 to +16
router.patch("/descriptions", ctrl.process.updateDescription);
router.patch("/checkboxes", ctrl.process.checkbox);
Copy link
Collaborator

Choose a reason for hiding this comment

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

이에 관한건 당장에는 이해하기 어려운 내용이라 피드백 드리고 수정을 요청하진 않겠습니다.
그래도 참조하시라고 링크 남겨봅니다.
https://www.freecodecamp.org/korean/news/rest-api-mobeom-sarye-rest-endeupointeu-seolgye-yesi/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

참조하겠습니다!!

Copy link
Collaborator

@hobiJeong hobiJeong left a comment

Choose a reason for hiding this comment

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

이해하기 힘든 내용이 있다면 말씀해주세요

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.

4 participants