refactor(client): ♻️ improve sendCommand flexibility and type checking

This commit is contained in:
Julien Oculi 2024-06-25 12:49:21 +02:00
parent 75959df9c2
commit 994254a1a5

View file

@ -73,14 +73,18 @@
/**
* Send command to the robot.
*
* @param {string} endpoint Address IP of the robot
* @param {string} endpoint Address IP of the robot.
* @param {Command} command Command to send.
* @param {number} value Value of the command if needed.
*
* @returns {Promise<void>}
*/
async function sendCommand(endpoint, command, value) {
const response = await fetch(
`http://${endpoint}/get?command=${command}&value=${value}`
const url = new URL(
`/get?command=${command}&value=${value}`,
endpoint
)
const response = await fetch(url)
const text = await response.text()
console.log(text)
}