-
Notifications
You must be signed in to change notification settings - Fork 35
[김지희] 스프린트미션 2 #23
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
The head ref may contain hidden characters: "\uAE40\uC9C0\uD76C"
[김지희] 스프린트미션 2 #23
Conversation
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.
요소요소에 WoW 포인트 들이 있었습니다.
엄청난 보석을 발견한 기분이에요!
그럼에도 아직 고쳐야할 부분들은 있으나, 그 부분들이 사소한 부분들이거나, 아직 많은 코드를 작성하지 않아서 나오는 부분들인 것같아요 !
이대로만 하신다면 굉장히 좋을 것 같네요 !
const instance = axios.create({ | ||
baseURL: 'https://panda-market-api-crud.vercel.app' | ||
}); |
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.
axios 의 create를 통해 instance를 기본적으로 만들어 내다니요 !
감탄했습니다 너무 좋은 코드를 보여주는 단 3줄이네요 ! 👍🏼
export class Article { | ||
#likeCount; | ||
|
||
constructor(title, content, writer, likeCount = 0, createdAt = new Date()) { | ||
this.title = title; | ||
this.writer = writer; | ||
this.#likeCount = likeCount; | ||
this.content = content; | ||
this.createdAt = createdAt; | ||
} | ||
getLikeCount(){ | ||
return this.#likeCount; | ||
} | ||
|
||
like() { | ||
this.#likeCount += 1 | ||
return this.likeCount; | ||
} | ||
} |
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.
Article 클래스를 Service 안에 녹이기보다는 따로 분리하여 import 하는건 어떨까요 !
this.title = title; | ||
this.writer = writer; | ||
this.#likeCount = likeCount; | ||
this.content = content; | ||
this.createdAt = createdAt; |
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.
다른 변수들도 #
를 통해서 private 하여 캡슐화/추상화 를 진행해보는건 어떨까요 !
|
||
like() { | ||
this.#likeCount += 1 | ||
return this.likeCount; |
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.
해당 부분에 return this.#likeCount
가 되어야 할 것 같습니다 !
constructor(title, content, writer, likeCount = 0, createdAt = new Date()) { | ||
this.title = title; | ||
this.writer = writer; | ||
this.#likeCount = likeCount; |
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.
likeCount 를 받을때 음수 체크를 해보면 더 안정적인 코드가 작성 될 것 같아요 !
if (likeCount < 0) {
throw ...
}
} | ||
|
||
export async function createArticle(articleBody){ | ||
const res = instance. post(`/articles`,articleBody) |
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.
instance.post
이렇게 붙여쓰는게 더 좋을 것 같네요 !
} | ||
|
||
export async function getArticle(id){ | ||
const res = instance.get(`/articles/${id}`) |
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.
template literal 을 적절하게 사용했네요 ! 👍🏼
return res; | ||
} | ||
|
||
export async function patchArticle (id, ArticleListType){ |
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.
ArticleListType 이 적절한 변수명이 아닌 듯합니다!
적절한 변수명은 가독성에 아주 중요한 역할을 하므로 변수명에 조금 더 신경을 써보면 좋을 것 같아요 !
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.
이 부분도 ProductService와 같은 리뷰들이 남겨집니다 !
import axios from 'axios'; | ||
const instance = axios.create({ | ||
baseURL: 'https://panda-market-api-crud.vercel.app' | ||
}); |
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.
여기서는 fetch를 한번 써보는건 어땠을까요 ! (공부할겸!)
요구사항
클래스 구현하기
요청함수 구현하기
GIT 사용하기
멘토에게