diff --git a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx index 57fe6831801ff..ded2bf278e738 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader/index.jsx @@ -121,15 +121,17 @@ export class ExploreChartHeader extends React.PureComponent { async fetchChartDashboardData() { const { dashboardId, slice } = this.props; - const response = await SupersetClient.get({ + await SupersetClient.get({ endpoint: `/api/v1/chart/${slice.slice_id}`, - }); - const chart = response.json.result; - const dashboards = chart.dashboards || []; - const dashboard = - dashboardId && - dashboards.length && - dashboards.find(d => d.id === dashboardId); + }) + .then(res => { + const response = res?.json?.result; + if (response && response.dashboards && response.dashboards.length) { + const { dashboards } = response; + const dashboard = + dashboardId && + dashboards.length && + dashboards.find(d => d.id === dashboardId); if (dashboard && dashboard.json_metadata) { // setting the chart to use the dashboard custom label colors if any diff --git a/tests/integration_tests/reports/api_tests.py b/tests/integration_tests/reports/api_tests.py index 9440855a62a51..3b6f1b5527a1a 100644 --- a/tests/integration_tests/reports/api_tests.py +++ b/tests/integration_tests/reports/api_tests.py @@ -273,11 +273,13 @@ def test_get_list_report_schedule(self): "changed_by", "changed_on", "changed_on_delta_humanized", + "chart_id", "created_by", "created_on", "creation_method", "crontab", "crontab_humanized", + "dashboard_id", "description", "id", "last_eval_dttm",