Skip to content

Commit

Permalink
fix(ajax): mark all options as optionnal
Browse files Browse the repository at this point in the history
  • Loading branch information
DjLeChuck committed Nov 29, 2024
1 parent 18a019f commit b1b7f79
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/fetch-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 = {}) => {
Expand Down

0 comments on commit b1b7f79

Please sign in to comment.