The API allows you to access my favorite color from anywhere
and to use it in other webpages, programs or objects.
You can link anything to be of my favorite color and it will automatically update,
following the changes.
Here is an example with javascript to use it as a css color on other webpages:
const url = "https://myfavoritecolor.dorian.systems/api.php";
const xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200){
var style = document.createElement('style');
style.innerHTML = '.dorian-favorite-color {color:' + xmlHttp.response + ';}';
document.head.appendChild(style);
}
}
xmlHttp.open("GET", url, true);
xmlHttp.send(null);