-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrack_api_util.js
55 lines (50 loc) · 964 Bytes
/
track_api_util.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
export const createTrack = (track, success, error) => {
$.ajax({
method: 'POST',
url: '/api/tracks',
data: track,
contentType: false,
processData: false,
success,
error
});
};
export const updateTrack = (track, success, error) => {
$.ajax({
method: 'PATCH',
url: '/api/tracks/:id',
data: { track },
dataType: 'json',
contentType: false,
processData: false,
success,
error
});
};
export const deleteTrack = (track, success, error) => {
$.ajax({
method: 'DELETE',
url: '/api/tracks/:id',
data: { track },
success,
error: () => {
console.log("Track Delete error in TrackApiUtil#deleteTrack");
}
});
};
export const fetchLatestTracks = (success, error) => {
$.ajax({
method: 'GET',
url: '/api/tracks',
success,
error
});
};
export const fetchCurrentTrackView = (id, success, error) => {
$.ajax({
method: 'GET',
url: `/api/tracks/${id}`,
success,
error
});
};