summaryrefslogtreecommitdiffstats
path: root/src/services/ChatService.js
blob: d077e9bd35fb9fb58ce844466f055e2edc7cac02 (plain)
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
import axios from "axios";
import error_notify from './NotifyErrorService.js'

const url = 'http://localhost:8000/api/chat/'

export default {
    async group_create(data) {
        return await axios
        .post(url+'groups/', data)
        .then(res => {
            return {
                status: res.status
            }
        })
        .catch(error => error_notify(error))
    },

    async get_all_user_groups() {
        return await axios
        .get(url+'groups/')
        .then(res => {
            return {
                status: res.status,
                data: res.data
            }
        })
        .catch(error => error_notify(error))
    },

    async get_group_messages(group_pk) {
        return await axios
        .get(url+`groups/detail/${group_pk}/messages/`)
        .then(res => {
            return {
                status: res.status,
                data: res.data
            }
        })
        .catch(error => error_notify(error))
    }
}