File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
src/domains/community/write Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -31,17 +31,21 @@ function WriteSection({ setIsOpen }: Props) {
3131 const handleSubmit = async ( e : React . FormEvent ) => {
3232 e . preventDefault ( ) ;
3333
34+ const payload = new FormData ( ) ;
35+ const postJson = {
36+ title : formData . title ,
37+ content : formData . content ,
38+ categoryId : 1 ,
39+ } ;
40+
41+ const postBlob = new Blob ( [ JSON . stringify ( postJson ) ] , { type : 'application/json' } ) ;
42+ payload . append ( 'post' , postBlob ) ;
43+
3444 try {
3545 const res = await fetch ( `${ getApi } /posts` , {
3646 method : 'POST' ,
37- headers : {
38- 'Content-Type' : 'application/json; charset=UTF-8' ,
39- } ,
40- body : JSON . stringify ( {
41- title : formData . title ,
42- content : formData . content ,
43- categoryName : formData . categoryName ,
44- } ) ,
47+ credentials : 'include' ,
48+ body : payload ,
4549 } ) ;
4650
4751 console . log ( '▶ 요청 보낸 후 status:' , res . status ) ;
You can’t perform that action at this time.
0 commit comments