@@ -35,6 +35,32 @@ export async function getBoardList(pageParam: number) {
35
35
}
36
36
}
37
37
38
+ export async function deleteBoard ( boardId : number ) {
39
+ const url = `/endpoint/api/board/remove/${ boardId } ` ;
40
+ try {
41
+ const response = await fetch ( url , {
42
+ method : 'DELETE' ,
43
+ credentials : 'include' ,
44
+ headers : {
45
+ 'Content-Type' : 'application/json' ,
46
+ } ,
47
+ } ) ;
48
+ if ( response . status === 401 ) {
49
+ throw new AuthError ( '로그인이 필요한 서비스입니다.' ) ;
50
+ }
51
+ if ( ! response . ok ) {
52
+ throw new Error ( `서버오류:${ response . status } ` ) ;
53
+ }
54
+ return await response . json ( ) ;
55
+ } catch ( error ) {
56
+ if ( error instanceof AuthError ) {
57
+ window . location . replace ( '/auth/login' ) ;
58
+ alert ( error . message ) ;
59
+ }
60
+ throw error ;
61
+ }
62
+ }
63
+
38
64
export async function postComment ( postCommentData : PostCommentType ) {
39
65
const url = `endpoint/api/reply/register` ;
40
66
const response = await fetch ( url , {
@@ -77,7 +103,13 @@ export async function getCommentList(
77
103
export async function deleteComment ( boardId : number , replyId : number ) {
78
104
const url = `/endpoint/api/reply/remove/${ boardId } /${ replyId } ` ;
79
105
try {
80
- const response = await fetch ( url ) ;
106
+ const response = await fetch ( url , {
107
+ method : 'DELETE' ,
108
+ credentials : 'include' ,
109
+ headers : {
110
+ 'Content-Type' : 'application/json' ,
111
+ } ,
112
+ } ) ;
81
113
if ( response . status === 401 ) {
82
114
throw new AuthError ( '로그인이 필요한 서비스입니다.' ) ;
83
115
}
0 commit comments