Skip to content

Commit

Permalink
fix(*): fetch condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiarrowood committed Oct 27, 2023
1 parent 07da2cc commit f34a631
Showing 1 changed file with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,28 +344,22 @@ onMounted(async () => {
isLoading.value = true
emit('loading', isLoading.value)
// only fetch available plugins if needed
if (props.onlyAvailablePlugins) {
try {
const res = await axiosInstance.get(availablePluginsUrl.value)
// TODO: endpoints temporarily return different formats
if (props.config.app === 'konnect') {
const { names: available } = res.data
availablePlugins.value = available || []
} else if (props.config.app === 'kongManager') {
const { plugins: { available_on_server: aPlugins } } = res.data
availablePlugins.value = aPlugins ? Object.keys(aPlugins) : []
}
pluginsList.value = buildPluginList()
emit('plugin-list-updated', pluginsList.value)
} catch (error: any) {
fetchErrorMessage.value = getMessageFromError(error)
try {
const res = await axiosInstance.get(availablePluginsUrl.value)
// TODO: endpoints temporarily return different formats
if (props.config.app === 'konnect') {
const { names: available } = res.data
availablePlugins.value = available || []
} else if (props.config.app === 'kongManager') {
const { plugins: { available_on_server: aPlugins } } = res.data
availablePlugins.value = aPlugins ? Object.keys(aPlugins) : []
}
} else {
pluginsList.value = buildPluginList()
emit('plugin-list-updated', pluginsList.value)
} catch (error: any) {
fetchErrorMessage.value = getMessageFromError(error)
}
isLoading.value = false
Expand Down

0 comments on commit f34a631

Please sign in to comment.