mirror of
https://github.com/koel/koel
synced 2024-12-22 10:33:16 +00:00
33 lines
909 B
JavaScript
33 lines
909 B
JavaScript
import Vue from 'vue';
|
|
|
|
/**
|
|
* Responsible for all HTTP requests.
|
|
*/
|
|
export const http = {
|
|
request(method, url, data, successCb = null, errorCb = null) {
|
|
return Vue.http[method](url, data).then(successCb, errorCb);
|
|
},
|
|
|
|
get(url, successCb = null, errorCb = null) {
|
|
return this.request('get', url, {}, successCb, errorCb);
|
|
},
|
|
|
|
post(url, data, successCb = null, errorCb = null) {
|
|
return this.request('post', url, data, successCb, errorCb);
|
|
},
|
|
|
|
put(url, data, successCb = null, errorCb = null) {
|
|
return this.request('put', url, data, successCb, errorCb);
|
|
},
|
|
|
|
delete(url, data = {}, successCb = null, errorCb = null) {
|
|
return this.request('delete', url, data, successCb, errorCb);
|
|
},
|
|
|
|
/**
|
|
* A shortcut method to ping and check if the user session is still valid.
|
|
*/
|
|
ping() {
|
|
return this.get('/');
|
|
},
|
|
};
|