typescript-typenfehler behoben.. npm run lint läuft nun fehlerfrei durch.
This commit is contained in:
@@ -5,17 +5,19 @@ function extractErrorMessage(payload: unknown): string {
|
||||
return 'coupon_error_generic';
|
||||
}
|
||||
|
||||
const data = payload as Record<string, any>;
|
||||
const data = payload as Record<string, unknown>;
|
||||
|
||||
if (data.message && typeof data.message === 'string') {
|
||||
if (typeof data.message === 'string') {
|
||||
return data.message;
|
||||
}
|
||||
|
||||
if (data.errors) {
|
||||
const errors = data.errors as Record<string, string[]>;
|
||||
if (data.errors && typeof data.errors === 'object') {
|
||||
const errors = data.errors as Record<string, unknown>;
|
||||
const firstKey = Object.keys(errors)[0];
|
||||
if (firstKey && Array.isArray(errors[firstKey]) && errors[firstKey][0]) {
|
||||
return errors[firstKey][0];
|
||||
const firstEntry = firstKey ? errors[firstKey] : undefined;
|
||||
|
||||
if (Array.isArray(firstEntry) && typeof firstEntry[0] === 'string') {
|
||||
return firstEntry[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user