From b13fb1c574585e3e96e563e5cf166707f6df8d35 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 17 Jan 2022 15:22:12 +0100 Subject: [PATCH] Add jsdoc block to http utility functions --- assets/js/utils/http.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/assets/js/utils/http.js b/assets/js/utils/http.js index 2314ad42..74479849 100644 --- a/assets/js/utils/http.js +++ b/assets/js/utils/http.js @@ -15,6 +15,15 @@ * This module implements the functionality of HTTP requests. */ window.App.Utils.Http = (function () { + /** + * Perform an HTTP request. + * + * @param {String} method + * @param {String} url + * @param {Object} data + * + * @return {Promise} + */ function request(method, url, data) { return new Promise((resolve, reject) => { fetch(App.Utils.Url.siteUrl(url), { @@ -58,7 +67,16 @@ window.App.Utils.Http = (function () { }); } - function upload(user, method, url, file) { + /** + * Upload the provided file. + * + * @param {String} method + * @param {String} url + * @param {File} file + * + * @return {Promise} + */ + function upload(method, url, file) { const formData = new FormData(); formData.append('file', file, file.name); @@ -100,7 +118,15 @@ window.App.Utils.Http = (function () { }); } - function download(user, method, url) { + /** + * Download the requested URL. + * + * @param {String} method + * @param {String} url + * + * @return {Promise} + */ + function download(method, url) { return new Promise((resolve, reject) => { fetch(App.Utils.Url.siteUrl(url), { method,