Add DRP document

This commit is contained in:
Mulia Nasution
2023-06-06 04:49:08 +07:00
parent adb490bacc
commit 89577aa56e
8 changed files with 742 additions and 362 deletions

45
src/utils/http.js Normal file
View File

@@ -0,0 +1,45 @@
const http = {
async request(method, url, data, headers = {}) {
try {
const defaultHeaders = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
headers = Object.assign(defaultHeaders, headers);
const options = {
method: method,
body: JSON.stringify(data),
headers,
}
if (method === 'GET') {
delete options.body;
}
return await fetch(url, options)
} catch (e) {
console.error(e)
}
},
async get(url, headers = {}) {
return await this.request('GET', url, null, headers);
},
async post(url, data, headers) {
return await this.request('POST', url, data, headers);
},
async put(url, data, headers) {
return await this.request('PUT', url, data, headers);
},
async delete(url, data, headers) {
return await this.request('DELETE', url, data, headers);
},
}
export default http;