-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgrades.js
More file actions
50 lines (48 loc) · 1.51 KB
/
Copy pathgrades.js
File metadata and controls
50 lines (48 loc) · 1.51 KB
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
import axios from "axios";
import authenticator from "../authenticator";
const auth = authenticator
let api = axios.create({
baseURL: process.env.EDUCLOUD_URL,
timeout: 1000,
})
export default {
api,
async getAllGrades() {
return await this.api.get("/grades", {
headers: {
"Authorization": await auth.asAuthorizationHeader()
}
}).then(({data}) => {
return data.data
}).catch(error => {
if (error.response) {
console.log(error.response.data)
console.log(error.response.status)
console.log(error.response.headers)
} else if (error.request) {
console.log(error.request)
} else {
console.log('Error', error.message)
}
console.log(error.config)
})
},
async getGrade(id) {
return await this.api.get(`/grades/${id}`, {
headers: { "Authorization": await auth.asAuthorizationHeader() }
}).then(({data}) => {
return data
}).catch(error => {
if (error.response) {
console.log(error.response.data)
console.log(error.response.status)
console.log(error.response.headers)
} else if (error.request) {
console.log(error.request)
} else {
console.log('Error', error.message)
}
console.log(error.config)
})
},
}