]>
git.r.bdr.sh - rbdr/dasein/blob - app/components/post_form.js
cee17b0785e8bceea716e7e79139acfe3d1694d6
1 import Axios
from 'axios';
3 import AuthService
from '../services/auth';
7 internals
.kPostsRoute
= '/api/posts';
9 export default internals
.PostFormComponent
= Vue
.component('post-form', {
10 template: '<div class="post-form-container">' +
12 '<textarea :disabled="submitting" v-model="content" class="post-content-input" placeholder="tell us something" maxlength=255></textarea>' +
13 '<p v-show="message" class="post-form-error">{{message}}</p>' +
14 '<button :disabled="submitting" class="post-submit" v-on:click="submit">Go.</button>' +
23 authService: new AuthService()
30 this.submitting
= true;
35 Authorization: `Bearer ${this.authService.token}`
40 url: internals
.kPostsRoute
41 }).then((response
) => {
43 this.$emit('post-submitted', response
.data
);
46 this.submitting
= false;
49 console
.error(err
.stack
);
50 this.submitting
= false;
51 this.message
= 'Error while creating the post...';