temperature-alarm/frontend/scripts/services/devices.service.js
2025-03-25 16:11:14 +01:00

39 lines
1.1 KiB
JavaScript

import { address } from "../../shared/constants.js";
export function getDevicesOnUserId(userId) {
fetch(`${address}/device/${userId}`, {
method: "GET",
headers: {
"Content-Type": "application/json"
},
})
.then(response => response.json())
.then(data => console.log("Success:", data))
.catch(error => console.error("Error:", error));
}
export function update(ids) {
fetch(`${address}/get-on-user-id`, {
method: "PATCH",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ ids: ids })
})
.then(response => response.json())
.then(data => console.log("Success:", data))
.catch(error => console.error("Error:", error));
}
export function getLogsOnDeviceIds(id) {
fetch(`${address}/get-on-device-ids`, {
method: "GET",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ ids: id })
})
.then(response => response.json())
.then(data => console.log("Success:", data))
.catch(error => console.error("Error:", error));
}