summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-12-20 16:34:55 +0100
committerBackportbot <backportbot-noreply@rullzer.com>2019-01-11 10:08:33 +0000
commitde5b172a69de4fa788046552a7028a8adcbd1421 (patch)
tree52bf3ecbdbfab50aa438ea2125bcd9af8024d67a
parent95a087d860cb6ec181a4de1f9576f4c8ba39aeb8 (diff)
Properly return promise when creating a new post (fixes #247)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--src/store/timeline.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/store/timeline.js b/src/store/timeline.js
index c31fb245..e816f41d 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -66,12 +66,16 @@ const actions = {
context.commit('setAccount', account)
},
post(context, post) {
- return axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
- // eslint-disable-next-line no-console
- console.log('Post created with token ' + response.data.result.token)
- }).catch((error) => {
- OC.Notification.showTemporary('Failed to create a post')
- console.error('Failed to create a post', error)
+ return new Promise((resolve, reject) => {
+ axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
+ // eslint-disable-next-line no-console
+ console.log('Post created with token ' + response.data.result.token)
+ resolve(response)
+ }).catch((error) => {
+ OC.Notification.showTemporary('Failed to create a post')
+ console.error('Failed to create a post', error.response)
+ reject(error)
+ })
})
},
refreshTimeline(context) {