Hey everyone,
I'm working with a desktop music player that has an API allowing for remote control of the player.
I'm trying to create a website that has basic controls for the player... pause, play, skip, and maybe a button for full volume / background music volume.
The API documentation calls for the following, for example:
I've tried the following code, but I'm getting no response and the console isn't logging anything either:
Sorry if this is super simple, I've been out of JS for a super long time and I don't really remember how to work with it
I'm working with a desktop music player that has an API allowing for remote control of the player.
I'm trying to create a website that has basic controls for the player... pause, play, skip, and maybe a button for full volume / background music volume.
The API documentation calls for the following, for example:
Code:
POST http://localhost:9863/query
"command": String,
"value": String (optional)
track-play - Play music
I've tried the following code, but I'm getting no response and the console isn't logging anything either:
Code:
<html>
<script>
document.getElementById("play").addEventListener('click', async _ => {
try {
const response = await fetch('http://localhost:9863/query', {
method: 'post',
command: 'track-play'
});
console.log('Completed!', response);
} catch(err) {
console.error(`Error: ${err}`);
}
});
</script>
<body>
<p>Click the button play</p>
<button id="play">play </button>
</body>
</html>
Sorry if this is super simple, I've been out of JS for a super long time and I don't really remember how to work with it