-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasyhttp3.js
51 lines (44 loc) · 1.17 KB
/
easyhttp3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Custom HTTP Library CRUD
class EasyHTTP3 {
// HTTP Get Request
async get(url) {
const responce = await fetch(url);
const data = await responce.json();
return data;
}
// HTTP POST Request
async post(url, formData) {
const responce = await fetch(url, {
method: 'POST',
headers: {
'Content-type': 'apllication/json'
},
body: JSON.stringify(formData)
});
const data = await responce.json();
return data;
}
// HTTP PUT Request
async put(url, formData) {
const responce = await fetch(url, {
method: 'PUT',
headers: {
'Content-type': 'apllication/json'
},
body: JSON.stringify(formData)
});
const data = await responce.json();
return data;
}
// HTTP DELETE Request
async delete(url) {
const responce = await fetch(url, {
method: 'DELETE',
headers: {
'Content-type': 'apllication/json'
},
});
const data = await 'Resource Deleted...';
return data;
}
}