Skip to content

Conversation

@gitit-emkoo
Copy link
Collaborator

@gitit-emkoo gitit-emkoo commented Nov 25, 2024

요구사항

기본 요구사항

  • 공통
  • Github에 스프린트 미션 PR을 만들어 주세요.
  • getArticleList() : GET 메서드를 사용해 주세요.
  • page, pageSize, keyword 쿼리 파라미터를 이용해 주세요.
  • getArticle() : GET 메서드를 사용해 주세요.
  • createArticle() : POST 메서드를 사용해 주세요.
  • request body에 title, content, image 를 포함해 주세요.
  • patchArticle() : PATCH 메서드를 사용해 주세요.
  • deleteArticle() : DELETE 메서드를 사용해 주세요.
  • fetch 혹은 axios 를 이용해 주세요.
  • 응답의 상태 코드가 2XX가 아닐 경우, 에러메시지를 콘솔에 출력해 주세요.

  • .then() 메서드를 이용하여 비동기 처리를 해주세요.

  • .catch() 를 이용하여 오류 처리를 해주세요.

  • 'https://sprint-mission-api.vercel.app/products' API를 이용하여 아래 함수들을 구현해 주세요.

  • getProductList() : GET 메서드를 사용해 주세요.

  • page, pageSize, keyword 쿼리 파라미터를 이용해 주세요.

  • getProduct() : GET 메서드를 사용해 주세요.

  • createProduct() : POST 메서드를 사용해 주세요.

  • request body에 name, description, price, tags, images 를 포함해 주세요.

  • patchProduct() : PATCH 메서드를 사용해 주세요.

  • deleteProduct() : DELETE 메서드를 사용해 주세요.

  • async/await 을 이용하여 비동기 처리를 해주세요.

  • try/catch 를 이용하여 오류 처리를 해주세요.

  • 구현한 함수들을 아래와 같이 파일을 분리해 주세요.

  • export를 활용해 주세요.

  • ProductService.js 파일 Product API 관련 함수들을 작성해 주세요.

  • ArticleService.js 파일에 Article API 관련 함수들을 작성해 주세요.

  • 이외의 코드들은 모두 main.js 파일에 작성해 주세요.

  • import를 활용해 주세요.

  • 각 함수를 실행하는 코드를 작성하고, 제대로 동작하는지 확인해 주세요.

이번 레슨은 어땠나요?

주요 변경사항

멘토에게

  • WSL 재설치 때문에 기존에 작업하던 로컬디렉토리가 변경되어 뭔가 이상하게 설정된것 같습니다..
  • 함수를 실행하는 코드작성 부분 잘 모르겠습니다..try문 사용하는건가요?
  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@gitit-emkoo gitit-emkoo self-assigned this Nov 25, 2024
@gitit-emkoo gitit-emkoo added 미완성🫠 완성은 아니지만 제출합니다... 제출일 이후 제출한PR 제출 마감일(일요일) 이후에 제출하는 PR입니다. labels Nov 25, 2024
@gitit-emkoo gitit-emkoo marked this pull request as draft November 25, 2024 02:20
@gitit-emkoo gitit-emkoo requested a review from seobew November 25, 2024 02:20
@gitit-emkoo gitit-emkoo marked this pull request as ready for review November 26, 2024 05:09
Copy link

@seobew seobew left a comment

Choose a reason for hiding this comment

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

은모님 이번 스프린트도 고생많으셨습니다!

WSL 재설치때문에 힘드셨겠어요 ㅠ 개발환경 한번 폭파되면 스트레스 많이 받는데 ㅠ

몇가지 코멘트들 남겨놨으니 확인 부탁드려요~
수고하셨씁니다!


export async function getProductList(page, pageSize, keyword) {
const res = await fetch(
`https://sprint-mission-api.vercel.app/products?page=${page}&pageSize=${pageSize}&keyword=${keyword}`
Copy link

Choose a reason for hiding this comment

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

https://sprint-mission-api.vercel.app 이부분까지는 따로 변수로 빼서 사용하는게 가독성도 좋고, 만약 host가 변경되었을때 일일이 수정안해줘도 되어서 좋습니다 ㅎㅎ


export async function deleteArticle() {
const res = await fetch("https://sprint-mission-api.vercel.app/articles", {
method: "DELET",
Copy link

Choose a reason for hiding this comment

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

여기 method에서 오타입니다.

*/

export async function createArticle(title, content, image) {
const res = await fetch("https://sprint-mission-api.vercel.app/articles", {
Copy link

Choose a reason for hiding this comment

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

여기는 위에 처럼 return fetch 만 해줘도 될것 같습니다

"content-type": "application/json",
},
})
.then((res) => {
Copy link

Choose a reason for hiding this comment

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

위에서도 res 값을 써서 헷갈릴수 있으므로 변수를 다르게 가져가는게 좋을듯 합니다!

try {
const res = await fetch("https://sprint-mission-api.vercel.app/products", {
method: "PATCH",
body: JSON.stringify(data),
Copy link

Choose a reason for hiding this comment

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

pathProduct 함수 파라미터에 data가 빠져있어서 여기서 참조를 할수 없습니다ㅠ



//제대로 동작하는지 확인
const data = await getArticleList({ page=1, pageSize=10, keyword=수정 });
Copy link

Choose a reason for hiding this comment

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

함수를 실행하는 코드작성 부분 잘 모르겠습니다..try문 사용하는건가요?

이게 실행하는 코드작성 입니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

미완성🫠 완성은 아니지만 제출합니다... 제출일 이후 제출한PR 제출 마감일(일요일) 이후에 제출하는 PR입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants