nuxt-outfit 1.4.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json
CHANGED
|
@@ -70,7 +70,7 @@ export const useForm = (opts = {}) => {
|
|
|
70
70
|
}
|
|
71
71
|
setErrors(unflatten(messages));
|
|
72
72
|
if (_onFail && isRunCallback) {
|
|
73
|
-
Promise.resolve(_onFail(errors, fail.status));
|
|
73
|
+
Promise.resolve(_onFail({ errors, status: fail.status }));
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
const handleSuccess = (hit) => {
|
|
@@ -80,8 +80,19 @@ export const useForm = (opts = {}) => {
|
|
|
80
80
|
Promise.resolve(_onSuccess(hit));
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
+
const makeRequest = (params, validated) => {
|
|
84
|
+
let body = validated;
|
|
85
|
+
if (otps?.isFormData) {
|
|
86
|
+
const formData = new FormData();
|
|
87
|
+
for (const [key, value] of Object.entries(body)) {
|
|
88
|
+
formData.append(key, typeof value === "object" ? JSON.stringify(value) : value);
|
|
89
|
+
}
|
|
90
|
+
body = formData;
|
|
91
|
+
}
|
|
92
|
+
return http(params?.action ?? opts?.action, { method: opts?.method ?? "POST", body });
|
|
93
|
+
};
|
|
83
94
|
const validate = (params) => {
|
|
84
|
-
return opts?.schema.validate(deepClone(fields), params?.validationOptions ?? { abortEarly: false }).then((validated) =>
|
|
95
|
+
return opts?.schema.validate(deepClone(fields), params?.validationOptions ?? { abortEarly: false }).then((validated) => makeRequest(params, validated)).then((hit) => handleSuccess(hit)).catch((fail) => handleFail(fail));
|
|
85
96
|
};
|
|
86
97
|
const handleSubmit = async (event = null, params) => {
|
|
87
98
|
processing();
|