Last active
June 16, 2021 21:05
-
-
Save gambinish/bb342a7ab406127406a599d5c0bf04f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is a test gist | |
class Device { | |
constructor(ipAddress) { | |
this.ipAddress = ipAddress; | |
} | |
sendStatus() { | |
const data = { ipAddress: this.ipAddress, deviceStatus: Math.floor(Math.random() * 3) }; | |
fetch(MESSAGE_QUEUE_POST_ENDPOINT, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
}, | |
body: JSON.stringify(data), | |
}) | |
.then((response) => response.json()) | |
.then((data) => { | |
console.log("Success:", data); | |
}) | |
.catch((error) => { | |
console.error("Error:", error); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment