-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
39 lines (37 loc) · 1.03 KB
/
api.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
const URL_API = "http://localhost:3300/";
export const getFlights = async () => {
const properties = await fetch(URL_API);
return await properties.json();
};
export const deleteFlight = async (seat) => {
const res = await fetch(URL_API + "delete/" + seat, {
method: "DELETE",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
return await res.json();
};
export const insertFlight = async (flight) => {
const res = await fetch(URL_API, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(flight),
});
return await res.json();
};
export const updateFlight = async (seat, flight) => {
const res = await fetch(URL_API + seat, {
method: "PUT",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify(flight), // Aquí se envían los datos del flighto en el cuerpo de la solicitud
});
return await res.json();
};