Skip to content

Commit

Permalink
Merge pull request #47 from sdslabs/add-download-counter
Browse files Browse the repository at this point in the history
Add a download counter
  • Loading branch information
ayanchoudhary authored Jun 24, 2020
2 parents d6273ea + 583d29b commit cd7b7a1
Show file tree
Hide file tree
Showing 3 changed files with 298 additions and 251 deletions.
36 changes: 24 additions & 12 deletions src/api/filesApi.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
import { axiosInstance } from 'api/axiosInstance';

function getFilesByCourse(id) {
return axiosInstance.get(`/files/?course=${id}&filetype=null&format=json`)
return axiosInstance.get(`/files/?course=${id}&filetype=null&format=json`)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function getFilesByType(id,type) {
function getFilesByType(id, type) {
return axiosInstance.get(`/files/?course=${id}&filetype=${type}&format=json`)
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

function downloadFiles(id) {
return axiosInstance.put(`/files`, { id, "downloads": "true" })
.then((response) => {
const res = JSON.parse(response.request.response);
return res;
})
.catch((error) => {
return Promise.reject(error);
});
}

export {
getFilesByCourse,
getFilesByType
getFilesByType,
downloadFiles
};
Loading

0 comments on commit cd7b7a1

Please sign in to comment.