Skip to content

Commit d775828

Browse files
Fix new story creation without attachments
1 parent 4c73b83 commit d775828

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pages/NewStory.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const NewStory = () => {
4848

4949
const [screenSize, setScreenSize] = useState(0)
5050

51-
const [attachments, setAttachments] = useState()
51+
const [attachments, setAttachments] = useState([])
5252

5353
useLayoutEffect(() => {
5454
function updateScreenSize() {
@@ -127,9 +127,11 @@ const NewStory = () => {
127127
data.Description = filterDescriptionText(description)
128128
const formData = new FormData()
129129
formData.append('data', JSON.stringify(data))
130-
attachments.forEach((file) => {
131-
formData.append('files.Attachment', file)
132-
})
130+
if (attachments.length) {
131+
attachments.forEach((file) => {
132+
formData.append('files.Attachment', file)
133+
})
134+
}
133135
await userStory.createStory(formData)
134136
navigate('/')
135137
}

0 commit comments

Comments
 (0)