[Enhancement] Add ApiClient, refactor CannedResponse (#183)

This commit is contained in:
Pranav Raj S
2019-10-27 10:48:26 +05:30
committed by GitHub
parent 50fc06681c
commit 6c60b60240
10 changed files with 311 additions and 322 deletions

View File

@@ -0,0 +1,31 @@
/* global axios */
const API_VERSION = `/api/v1`;
class ApiClient {
constructor(url) {
this.url = `${API_VERSION}/${url}`;
}
get() {
return axios.get(this.url);
}
show(id) {
return axios.get(`${this.url}/${id}`);
}
create(data) {
return axios.post(this.url, data);
}
update(id, data) {
return axios.patch(`${this.url}/${id}`, data);
}
delete(id) {
return axios.delete(`${this.url}/${id}`);
}
}
export default ApiClient;