Be the async await change
parent
3f0e78e256
commit
beb04bd3f6
|
@ -38,25 +38,27 @@ class KapacitorRulePage extends Component {
|
|||
})
|
||||
}
|
||||
|
||||
getKapacitorConfig(kapacitor)
|
||||
.then(({data: {sections}}) => {
|
||||
const enabledAlerts = Object.keys(sections).filter(section => {
|
||||
return (
|
||||
_.get(
|
||||
sections,
|
||||
[section, 'elements', '0', 'options', 'enabled'],
|
||||
false
|
||||
) && ALERTS.includes(section)
|
||||
)
|
||||
})
|
||||
this.setState({kapacitor, enabledAlerts})
|
||||
try {
|
||||
const {data: {sections}} = await getKapacitorConfig(kapacitor)
|
||||
const enabledAlerts = Object.keys(sections).filter(section => {
|
||||
return (
|
||||
_.get(
|
||||
sections,
|
||||
[section, 'elements', '0', 'options', 'enabled'],
|
||||
false
|
||||
) && ALERTS.includes(section)
|
||||
)
|
||||
})
|
||||
.catch(() => {
|
||||
addFlashMessage({
|
||||
type: 'error',
|
||||
text: 'There was a problem communicating with Kapacitor',
|
||||
})
|
||||
|
||||
this.setState({kapacitor, enabledAlerts})
|
||||
} catch (error) {
|
||||
addFlashMessage({
|
||||
type: 'error',
|
||||
text: 'There was a problem communicating with Kapacitor',
|
||||
})
|
||||
console.error(error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -143,11 +143,11 @@ export function updateKapacitor({
|
|||
})
|
||||
}
|
||||
|
||||
export function getKapacitorConfig(kapacitor) {
|
||||
return kapacitorProxy(kapacitor, 'GET', '/kapacitor/v1/config', '')
|
||||
export const getKapacitorConfig = async kapacitor => {
|
||||
return await kapacitorProxy(kapacitor, 'GET', '/kapacitor/v1/config', '')
|
||||
}
|
||||
|
||||
export function getKapacitorConfigSection(kapacitor, section) {
|
||||
export const getKapacitorConfigSection = (kapacitor, section) => {
|
||||
return kapacitorProxy(kapacitor, 'GET', `/kapacitor/v1/config/${section}`, '')
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue