This commit is contained in:
2025-07-13 17:18:02 +09:00
parent 0c46cf28db
commit 9e0eb3b3c5
9 changed files with 173 additions and 92 deletions
+13 -10
View File
@@ -28,22 +28,25 @@ export default () => {
const previousURLRef = useRef ('')
const handleSubmit = async () => {
const formData = new FormData ()
const formData = new FormData
formData.append ('title', title)
formData.append ('url', url)
formData.append ('tags', tags)
if (thumbnailFile)
formData.append ('thumbnail', thumbnailFile)
void (axios.post (`${ API_BASE_URL }/posts`, formData, { headers: {
'Content-Type': 'multipart/form-data',
'X-Transfer-Code': localStorage.getItem ('user_code') || '' } })
.then (() => {
toast ({ title: '投稿成功!' })
navigate ('/posts')
})
.catch (() => toast ({ title: '投稿失敗',
description: '入力を確認してください。' })))
try
{
await axios.post (`${ API_BASE_URL }/posts`, formData, { headers: {
'Content-Type': 'multipart/form-data',
'X-Transfer-Code': localStorage.getItem ('user_code') ?? '' } })
toast ({ title: '投稿成功!' })
navigate ('/posts')
}
catch
{
toast ({ title: '投稿失敗', description: '入力を確認してください。' })
}
}
useEffect (() => {