-
Notifications
You must be signed in to change notification settings - Fork 2
/
httpRequests.ts
39 lines (35 loc) · 1.04 KB
/
httpRequests.ts
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
const url = "http://194.163.169.207:8080/tour-app/tours";//"http://194.163.169.207:8080/tour-app/tours"
export async function post(path: string, body: any) {
let response = await fetch(url + path, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
return await response.json();
}
export async function get(path: string) {
let response = await fetch(url + path);
return await response.json();
}
export async function put(path: string, body: any) {
let response = await fetch(url + path, {
method: "PUT",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
return await response.json();
}
export async function patch(path: string, body: any) {
let response = await fetch(url + path, {
method: "PATCH",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(body)
});
return await response.json();
}