diff --git a/specifyweb/frontend/js_src/lib/utils/ajax/index.ts b/specifyweb/frontend/js_src/lib/utils/ajax/index.ts index 0f2963b21b6..abe6d7160db 100644 --- a/specifyweb/frontend/js_src/lib/utils/ajax/index.ts +++ b/specifyweb/frontend/js_src/lib/utils/ajax/index.ts @@ -40,6 +40,11 @@ export type AjaxMethod = | 'POST' | 'PUT'; +/** + * These methods usually don't modify data, so if they fail it is not a big + * deal. If on the other than POST, PUT, DELETE, or PATCH request fails, it + * may cause data loss or data corruption + */ const safeMethods: ReadonlySet = new Set([ 'OPTIONS', 'GET', @@ -75,16 +80,13 @@ export type AjaxProps = Omit & { /** * All front-end network requests should go through this utility. * - * Wraps native fetch in useful helpers - * It is intended as a replacement for jQuery's ajax - * - * @remarks - * Automatically adds CSRF token to non GET requests - * Casts response to correct typescript type - * Parsers JSON and XML responses - * Handlers errors (including permission errors) + * Wraps native fetch in useful helpers: + * - Automatically adds CSRF token to non GET requests + * - Casts response to correct typescript type + * - Parses JSON and XML responses + * - Handlers errors (including permission errors) + * - Helps with request mocking in tests */ -// "errorMode" is optional for "GET" requests export async function ajax( url: string, /** These options are passed directly to fetch() */