I don't really have a specific use case in mind right at the moment but I just kind of started getting curious is this could be done. The documentation on api.php would suggest this should be possible and there is even an example in the JS documentation (see here).
However, when I tried, it doesn't seem to have had any effect. I checked by accessing api.php?action=query&meta=userinfo&uiprop=options and nothing changed. Am I doing something wrong, is this because Fandom is a wiki farm, or is this because Fandom has customized their installation to require use of a controller? Here is what I tried in my console.
new mw.Api().postWithToken(
"csrf",
{
action: "options",
optionname: "avatar",
optionvalue: "https://vignette.wikia.nocookie.net/messaging/images/1/19/Avatar.jpg"
}
).then(
function () {
console.log("success");
},
function () {
console.log("failure");
}
);