폼데이터(formData)로 사진 보내기
// 사진 업로드는 폼데이터로!!!!!!!!!
const formData = new FormData();
formData.append("title", uploadTitle);
formData.append("content", uploadContent);
formData.append("url", uploadUrl);
formData.append("image", uploadImage);
// 서버로 폼데이터 보냄
const response = await axios.post(`${serverUrl}/api/campaign`, formData, {
headers: {
Authorization: `Bearer ${token}`, // 로그인 여부 확인(토큰을 헤더에 추가)
"Content-Type": "multipart/form-data", // 필수: FormData를 보낼 때 content type 설정
},
});
'⛵ 항해99 > TIL · WIL ✏️' 카테고리의 다른 글
[TIL] 2023.09.27 - map(배열 조건 설정 방법) (0) | 2023.09.30 |
---|---|
[TIL] 2023.09.26 - git 명령어 정리 (0) | 2023.09.30 |
[TIL] 2023.09.23 - Local Storage / Cookie 메서드 (0) | 2023.09.23 |
[TIL] 2023.09.22 - 뒤로가기 / navigate(-1) (0) | 2023.09.22 |
[TIL] 2023.09.21 - Handler 사용 이유 (0) | 2023.09.21 |