forked from adonisjs/adonis-fullstack-app
/
Chat.js
50 lines (47 loc) · 1.09 KB
/
Chat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const axios = require('axios')
module.exports = {
props: ['lib', 'status', 'config', 'progress'],
data() {
this.$i18n.locale = this.config.locale
return {
displayMessages: [],
writingMessage: '',
users: []
}
},
computed: {
},
watch: {
},
mounted: function () {
this.loadUsers()
},
methods: {
loadUsers: async function () {
let users = await axios.get('http://127.0.0.1:3333/user/all')
this.users = users.data
},
/*
addUser: async function () {
let unixMS = (new Date()).getTime()
await axios.get('http://127.0.0.1:3333/user/create', {
params: {
username: 'Pudding' + unixMS,
email: 'pudding' + unixMS + '@pulipuli.info',
password: unixMS + ''
}
})
console.log('addUser')
this.loadUsers()
},
*/
send: async function () {
console.log(this.message)
},
logout: async function () {
await axios.get(`${this.config.baseURL}/logout`)
this.status.username = ''
this.$router.replace('/')
}
} // methods
}