-
Notifications
You must be signed in to change notification settings - Fork 1
/
APIs.js
69 lines (63 loc) · 2.33 KB
/
APIs.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
60
61
62
63
64
65
66
67
68
69
import axios from 'axios'
export const LoginEndpoint = '/users/login'
export const SignupEndpoint = '/users'
export const TokenFile = 'token'
export const UserFile = 'user'
export const firstTimeFile = '/first_time'
export const DoctorPatientAssignmentsEndpoint = '/doctor_patient_assignments'
export const InvitesEndpoint = '/invites'
export const DoctorPatientAssignmentsRemoveEndpoint = '/doctor_patient_assignments/remove'
export const getExercises = '/exercises'
export const getAssignments = '/assignments'
export const showAssignment = (id) => `/assignments/${id}`
export const createAssignment = '/assignments'
export const updateAssignment = (id) => `/assignments/${id}`
export const removeAssignment = (id) => `/assignments/${id}`
export const updateUserInfo = (id) => `/users/${id}`
export const doctorUpdateAssignment = (id) => `/assignments/${id}/doctor_update`
export const Announcements = '/announcements'
export const Announcement = (id) => `/announcements/${id}`
export const Likes = '/likes'
export const Like = (id) => `/likes/${id}`
export const Comments = '/comments'
export const Comment = (id) => `/comments/${id}`
export const fetchGlobal = async (endpoint) =>{
try{
const response = await axios.get(endpoint)
return {data: response.data, hasError: false}
} catch(err){
return {data: err, hasError: true}
}
}
export const postGlobal = async (endpoint,data) =>{
try{
const response = await axios.post(endpoint,data)
return {data: response.data, hasError: false}
} catch(err){
return {data: err, hasError: true}
}
}
export const putGlobal = async (endpoint,data) =>{
try{
const response = await axios.put(endpoint,data)
return {data: response.data, hasError: false}
} catch(err){
return {data: err, hasError: true}
}
}
export const putGlobalFormData = async (endpoint,data) =>{
try{
const response = await axios.put(endpoint,data, {headers: {'Content-Type': 'multipart/form-data'}})
return {data: response.data, hasError: false}
} catch(err){
return {data: err, hasError: true}
}
}
export const deleteGlobal = async (endpoint) =>{
try{
const response = await axios.delete(endpoint)
return {data: response.data, hasError: false}
} catch(err){
return {data: err, hasError: true}
}
}