다음으로 댓글 목록 조회를 위한 API 요청 함수를 api/comments.ts 파일에 작성하세요.

    api/comments.ts

    import client from './client';
    import {Comment} from './types';
    
    export async function getComments(articleId: number) {
      const response = await client.get<Comment[]>(
        `/articles/${articleId}/comments`,
      );
      return response.data;
    }

    이제 API를 위한 함수가 모두 준비됐습니다.

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.