-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.js
60 lines (57 loc) · 1.9 KB
/
index.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
51
52
53
54
55
56
57
58
59
import axios from 'axios'
export default function(options) {
let apiClient = axios.create({
baseURL: (options && options.baseUrl) || process.env.MIX_API_URL,
withCredentials: true,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
})
return {
token: null,
setToken: function(token) {
this.token = token
apiClient.defaults.headers.common['Authorization'] = 'Bearer ' + this.token;
},
series: async function() {
const response = await apiClient.get('/series')
return response.data
},
videos: async function() {
const response = await apiClient.get('/videos')
return response.data
},
login: async function(email,password,device_name) {
const postData = {
email,
password,
device_name,
}
const response = await apiClient.post('/sanctum/token', postData)
return response.data
},
user: async function() {
const response = await apiClient.get('/user')
return response.data
},
video: {
show: async function(id) {
const response = await apiClient.get('/videos/' + id)
return response.data
},
create: async function(data) {
const response = await apiClient.post('/videos',data)
return response.data
},
update: async function(id, data) {
const response = await apiClient.put('/videos/' + id,data)
return response.data
},
destroy: async function(id) {
const response = await apiClient.delete('/videos/' + id)
return response.data
},
}
}
}