[basic-박영서] sprint 3: 제출#29
Hidden character warning
[basic-박영서] sprint 3: 제출#29YoungSeo1104 wants to merge 13 commits intocodeit-sprint-fullstack:basic-박영서from
Conversation
| //type: (x: string, y: string, z: string) => void; | ||
| export const createArticle = ({ title, content, image }) => { | ||
| return instance | ||
| .post(`/articles`, { title, content, image }) |
| }; | ||
|
|
||
| //type: (x: number, y: string[]) => void; | ||
| export const patchArticle = (id, data) => { |
There was a problem hiding this comment.
무슨 데이터가 들어왔는지 알수 없습니다. validation이 필요해보입니다.
| }; | ||
|
|
||
| //type: (x: number) => void; | ||
| export const deleteArticle = (id) => { |
There was a problem hiding this comment.
delete flag 에 대해서 알고 계신가요? soft delete에 대해서 공부해보시면 좋겠습니다.
{
title: "안녕"
delete : false
}
| export const getArticleList = (params) => { | ||
| return instance | ||
| .get(`/articles`, { params }) | ||
| .then((res) => res.data) |
There was a problem hiding this comment.
상태 코드에 대해서 공부를 해보면 좋을거 같아요.
There was a problem hiding this comment.
|
|
||
| return await res.json(); | ||
| } catch (error) { | ||
| console.log('getProductList Error:', error.message); |
There was a problem hiding this comment.
로깅을 나중에 제대로 해보면 좋을거 같아요.
파일로 남긴다거나, 네트워크로 요청을 한다거나, db에 남긴다거나 하면 좋을거 같아요.
| deleteProduct, | ||
| } from './ProductService.js'; | ||
|
|
||
| const articleAPI = async () => { |
There was a problem hiding this comment.
실제 테스트코드 format으로 해보면 좋을거 같아요.
jest, mocha를 사용해보죠
|
|
||
| let loginCheck = false; | ||
|
|
||
| export const USER_DATA = [ |
| ]; | ||
|
|
||
| // type: (x:string, y: HTMLInputElement) => void; | ||
| export const EyesOnOffHandler = (id, input) => { |
There was a problem hiding this comment.
함수로 보이는데 eyesOnOffHandler로 네이밍 규칙을 잘 지켜주시면 좋을거 같아요~
| pwInput.addEventListener('input', (e) => inputHandler('password')); | ||
|
|
||
| if (loginBtn) { | ||
| //조건1 - 만약 입력한 이메일이 데이터베이스(USER_DATA)에 없거나, 이메일은 일치하지만 비밀번호가 틀린 경우, '비밀번호가 일치하지 않습니다.'라는 메시지를 alert로 표시합니다 |
| }); | ||
| } | ||
|
|
||
| if (pwInputCheck) { |
There was a problem hiding this comment.
파일이 너무 커진거 같아서 함수로 좀 분리해보면 좋을거 같습니다~
| } | ||
| }; | ||
|
|
||
| //type: (x: number) => void; |
There was a problem hiding this comment.
//type: (id: number) => void;
면 어떨까요?
실제 현업에서는
/**
* 상품을 삭제한다
*
* @param {number | string} id - 삭제할 상품 ID
* @returns {Promise<any>} 삭제 결과
* @throws {Error} 네트워크 오류 또는 서버 오류
*/
export const deleteProduct = async (id) => {
try {
const res = await fetch(`${PRODUCT_URL}/${id}`, {
method: 'DELETE',
});
if (!res.ok) {
throw new Error(res.statusText);
}
return await res.json();
} catch (error) {
console.error('deleteProduct Error:', error);
throw error;
}
};
이렇게 사용합니다
|
login.js 코드가 실무에서 협업하기 좋은 코드인지 피드백 받고 싶습니다. => 너무 역할이 많은거 같아서 좀 쪼개주시면 좋겠습니다. 함수의 매개변수(parameter)에 type을 적는 연습을 하고 있는데, 맞게 썼는지도 시간 되시면 확인 부탁드립니다! 면 어떨까요? 실제 현업에서는 이렇게 사용합니다 |
|
node_modules는 깃헙에 올리지 않습니다 gitignore를 공부하고 적용해주세요~ |
작업 반영 링크 - https://ys-sprint-pandamarket.netlify.app/
멘토님에게 남길 메시지