refactor(client): ♻️ improve sendCommand
flexibility and type checking
This commit is contained in:
parent
75959df9c2
commit
994254a1a5
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue