const address = "http://10.135.51.116/temperature-alarm-webapi/users" function login(username, password) { fetch(`${address}/login`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({username: username, password: password}) }) .then(response => response.json()) .then(data => console.log("Success:", data)) .catch(error => console.error("Error:", error)); } function create(email, username, password){ fetch(`${address}/create`, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({email: email, username: username, password: password}) }) .then(response => response.json()) .then(data => console.log("Success:", data)) .catch(error => console.error("Error:", error)); } function update(email, username, password){ fetch(`${address}/update`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({email: email, username: username, password: password}) }) .then(response => response.json()) .then(data => console.log("Success:", data)) .catch(error => console.error("Error:", error)); }