This commit is contained in:
parent
7a37993439
commit
d2dcfb6e2e
4 changed files with 80 additions and 20 deletions
|
@ -1,10 +1,13 @@
|
|||
<script setup lang='ts'>
|
||||
import { ref, type PropType, type ComponentObjectPropsOptions } from 'vue'
|
||||
import { resourceServer } from '@/main'
|
||||
import { type AxiosInstance } from 'axios'
|
||||
|
||||
import { resourceServer, axiosResourceProviders } from '@/main'
|
||||
|
||||
interface Props {
|
||||
resourceName: string,
|
||||
resourceId?: string,
|
||||
resourceProviderId?: string | number,
|
||||
resourceId?: string | null,
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
|
@ -23,8 +26,9 @@ let _title = ref<string>("")
|
|||
|
||||
const init = async (props: any) => {
|
||||
// Get code at component boot time
|
||||
const axiosResourceProvider: AxiosInstance = props.resourceProviderId ? axiosResourceProviders[props.resourceProviderId] : resourceServer
|
||||
const url = props.resourceId ? `${props.resourceName}/${props.resourceId}` : props.resourceName
|
||||
await resourceServer.get(url).then(
|
||||
await axiosResourceProvider.get(url).then(
|
||||
resp => {
|
||||
_class.value = `hasResponseStatus status-${resp.status}`
|
||||
_title.value = `Response code: ${resp.status} - ${resp.statusText}`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue