Skip to content

Commit ac396a6

Browse files
committed
feat: add onRequestError callback to useSanctumForm
1 parent 2a9ddad commit ac396a6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/runtime/composables/useSanctumForm.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ const resolveSubmitOptions = (
5858
form.setErrors({});
5959
options.onRequest?.(context);
6060
},
61+
async onRequestError(context) {
62+
form.processing = false;
63+
options.onRequestError?.(context);
64+
},
6165
async onResponse(context) {
6266
form.processing = false;
6367
options.onResponse?.(context);
@@ -115,7 +119,7 @@ export const useSanctumForm = <Data extends Record<string, unknown>>(
115119
async submit<T = any, R extends ResponseType = 'json'>(
116120
options: FetchOptions<R> = {},
117121
): Promise<MappedResponseType<R, T>> {
118-
let methodType = resolveMethod(method);
122+
const methodType = resolveMethod(method);
119123
let preparedData: Data | FormData = form.data();
120124

121125
// Convert to FormData if files are detected
@@ -124,12 +128,6 @@ export const useSanctumForm = <Data extends Record<string, unknown>>(
124128
indices: true,
125129
booleansAsIntegers: true,
126130
}) as FormData;
127-
128-
// Method spoofing for file uploads with non-POST methods
129-
if (methodType !== 'post') {
130-
preparedData.append('_method', methodType);
131-
methodType = 'post';
132-
}
133131
}
134132

135133
return useSanctumFetch(resolveUrl(url), {

0 commit comments

Comments
 (0)