This commit is contained in:
@@ -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 (() => {
|
||||
|
||||
Reference in New Issue
Block a user