-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch-utils.js
65 lines (58 loc) · 1.55 KB
/
fetch-utils.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const fetch = require("cross-fetch");
const API_URL = "https://terminalescaperoom.herokuapp.com";
async function fetchRoom() {
const response = await fetch(`${API_URL}/api/v1/rooms`, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
const data = await response.json();
return data;
}
async function fetchUserItem() {
const response = await fetch(`${API_URL}/api/v1/userItem`, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
const data = await response.json();
return data;
}
async function fetchItemsTable() {
const response = await fetch(`${API_URL}/api/v1/items`, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
const data = await response.json();
return data;
}
// async function fetchUser() {
// const response = await fetch(`${API_URL}/api/v1/Users`, {
// method: 'GET',
// headers: {
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
// });
// const data = await response.json();
// return data;
// }
// async function createUser() {
// const response = await fetch(`${API_URL}/api/v1/Users`, {
// method: 'PUT',
// headers: {
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
// });
// const data = await response.json();
// return data;
// }
module.exports = { fetchRoom, fetchUserItem, fetchItemsTable };