Skip to content

Commit

Permalink
chain async function
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdotson committed Mar 4, 2022
1 parent e045ce8 commit d87934c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions superset-frontend/src/views/CRUD/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ export function useDatabaseValidation() {
null,
);
const getValidation = useCallback(
(database: Partial<DatabaseObject> | null, onCreate = false) => {
(database: Partial<DatabaseObject> | null, onCreate = false) =>
SupersetClient.post({
endpoint: '/api/v1/database/validate_parameters',
body: JSON.stringify(database),
Expand All @@ -658,10 +658,10 @@ export function useDatabaseValidation() {
.then(() => {
setValidationErrors(null);
})
// eslint-disable-next-line consistent-return
.catch(e => {
setValidationErrors(null);
if (typeof e.json === 'function') {
e.json().then(({ errors = [] }: JsonObject) => {
return e.json().then(({ errors = [] }: JsonObject) => {
const parsedErrors = errors
.filter((error: { error_type: string }) => {
const skipValidationError = ![
Expand Down Expand Up @@ -749,12 +749,10 @@ export function useDatabaseValidation() {
);
setValidationErrors(parsedErrors);
});
} else {
// eslint-disable-next-line no-console
console.error(e);
}
});
},
// eslint-disable-next-line no-console
console.error(e);
}),
[setValidationErrors],
);

Expand Down

0 comments on commit d87934c

Please sign in to comment.