dashboard: POST to HTTP

Adds a menu option to POST the ASCII to a URL.
This commit is contained in:
chzchzchz 2021-08-18 23:22:13 -07:00
parent c45bfabcaa
commit 1b5ad5a8fe

View File

@ -64,6 +64,13 @@
>
Export mIRC to Clipboard
</li>
<li
class="ml-1 border-b"
@click="startExport('post')"
v-if="asciibirdMeta.length"
>
Post to HTTP
</li>
<li
@click="exportAsciibirdState()"
class="ml-1"
@ -420,6 +427,24 @@ export default {
case "file":
downloadFile(ascii.output.join(""), ascii.filename, "text/plain");
break;
case "post":
if (!this.lastPostURL) {
this.lastPostURL = "http://localhost:9991/bot/efnet?target=%23jrh";
}
let postURL = prompt("Enter URL for POST command", this.lastPostURL);
if (postURL == null) {
break;
}
this.lastPostURL = postURL;
const requestOptions = {
method: "POST",
headers: { "Content-Type": "application/octet-stream" },
body: ascii.output.join("")
};
fetch(postURL, requestOptions)
.then(response => this.$toasted.show("POSTed ascii!"))
.catch(error => this.$toasted.show("Error POSTing"));
break;
}
},
changeTab(key) {