From b1b7f79eb779493d954334e1a6b49182653e8592 Mon Sep 17 00:00:00 2001 From: Vivien DE BONA Date: Fri, 29 Nov 2024 09:31:27 +0100 Subject: [PATCH] fix(ajax): mark all options as optionnal --- src/fetch-utils.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fetch-utils.js b/src/fetch-utils.js index 21e1368..316e879 100644 --- a/src/fetch-utils.js +++ b/src/fetch-utils.js @@ -6,15 +6,15 @@ /** * @typedef {Object} FetchOptions - * @property {any} body - Request body. Throw an error if passed when the option `json` or `form` is used. - * @property {HTMLFormElement|null} form - HTML form. Will be passed in the `body` as `new FormData(form)` and his method will be automatically used as the request's HTTP method. - * @property {Headers|null} headers - HTTP headers. - * @property {Object|null} json - JSON payload. Will be passed in the `body` as `JSON.stringify(options.json)`. - * @property {string|null} method - HTTP method (GET, POST, etc.). If provided with the `form` option, it takes precedence. - * @property {Object} query - Hash of values used to append a query string to the URL. - * @property {Object} rawOptions - Additional raw options passed to `fetch`. - * @property {int} timeout - Timeout for the request execution. - * @property {boolean} unprocessableEntityAsError=true - Whether to treat 422 as an error. + * @property {any} [body] - Request body. Throw an error if passed when the option `json` or `form` is used. + * @property {HTMLFormElement|null} [form] - HTML form. Will be passed in the `body` as `new FormData(form)` and his method will be automatically used as the request's HTTP method. + * @property {Headers|null} [headers] - HTTP headers. + * @property {Object|null} [json] - JSON payload. Will be passed in the `body` as `JSON.stringify(options.json)`. + * @property {string|null} [method] - HTTP method (GET, POST, etc.). If provided with the `form` option, it takes precedence. + * @property {Object} [query] - Hash of values used to append a query string to the URL. + * @property {Object} [rawOptions] - Additional raw options passed to `fetch`. + * @property {int} [timeout] - Timeout for the request execution. + * @property {boolean} [unprocessableEntityAsError=true] - Whether to treat 422 as an error. */ import HttpError from './HttpError'; @@ -68,7 +68,7 @@ function _getJson(body) { * Execute a fetch call on the given URL and return a formatted Promise. * * @param {string} url - * @param {FetchOptions} options + * @param {FetchOptions} [options={}] * @returns {PromiseLike<{headers: Headers, json: any, body: string, status: number, statusText: string}|HttpError>} */ export const ajax = (url, options = {}) => {