diff --git a/Server/Sender.mjs b/Server/Sender.mjs index d37fceb..4a84652 100644 --- a/Server/Sender.mjs +++ b/Server/Sender.mjs @@ -37,6 +37,15 @@ class Sender { html_string(status_code, html_string) { this.string(status_code, "text/html", html_string); } + /** + * Sends a given thing of any type as a JSON response. + * @param {number} status_code The status code to return. + * @param {any} obj The thing to send - will be converted to JSON. + * @return {void} + */ + json(status_code, obj) { + this.string(status_code, "application/json", obj); + } /** * Sends a given string with a given content-type. * @param {number} status_code The status code to return.