Created
April 16, 2018 07:29
-
-
Save 197291/fd854b23466e2f68cc37926b491b9fc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Api { | |
get(url: string, config?: AxiosRequestConfig) { | |
return new Promise((resolve, reject) => { | |
axios.get(BASE_URL + url, config) | |
.then(({data}) => resolve(data)) | |
.catch(error => reject(error)); | |
}); | |
} | |
put(url: string, _data: any = {}) { | |
return new Promise((resolve, reject) => { | |
axios.put(BASE_URL + url, _data) | |
.then(({data}) => resolve(data)) | |
.catch(error => reject(error)); | |
}); | |
} | |
post(url: string, _data: any = {}) { | |
return new Promise((resolve, reject) => { | |
axios.post(BASE_URL + url, _data) | |
.then(({data}) => resolve(data)) | |
.catch(error => reject(error)); | |
}); | |
} | |
delete(url: string) { | |
return new Promise((resolve, reject) => { | |
axios.delete(BASE_URL + url) | |
.then(({data}) => resolve(data)) | |
.catch(error => reject(error)); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment