moved get merch list method
This commit is contained in:
parent
bd25bc90cf
commit
8b747f0a1e
2 changed files with 16 additions and 2 deletions
|
|
@ -21,6 +21,17 @@ export const useMerchApi = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMerchList = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiClient.get('/merch/')
|
||||||
|
if (response.status === 200) {
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const deleteMerch = async (uuid) => {
|
const deleteMerch = async (uuid) => {
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.delete(`/merch/${uuid}`)
|
const response = await apiClient.delete(`/merch/${uuid}`)
|
||||||
|
|
@ -33,6 +44,7 @@ export const useMerchApi = () => {
|
||||||
return {
|
return {
|
||||||
addMerch,
|
addMerch,
|
||||||
getMerchDetails,
|
getMerchDetails,
|
||||||
|
getMerchList,
|
||||||
deleteMerch,
|
deleteMerch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,17 @@
|
||||||
import CollectionToolbar from '@/views/CollectionView/CollectionToolbar.vue'
|
import CollectionToolbar from '@/views/CollectionView/CollectionToolbar.vue'
|
||||||
import CollectionMerchCard from '@/views/CollectionView/CollectionMerchCard.vue'
|
import CollectionMerchCard from '@/views/CollectionView/CollectionMerchCard.vue'
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
import { apiClient } from '@/services/apiClient.js'
|
import { useMerchApi } from '@/api/merch.js'
|
||||||
|
|
||||||
const merchList = ref(null)
|
const merchList = ref(null)
|
||||||
const loading = ref(true)
|
const loading = ref(true)
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
|
|
||||||
|
const { getMerchList } = useMerchApi()
|
||||||
|
|
||||||
const fetchMerch = async () => {
|
const fetchMerch = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.get('/merch/')
|
const response = await getMerchList()
|
||||||
if (!response.ok) throw new Error('Network error')
|
if (!response.ok) throw new Error('Network error')
|
||||||
merchList.value = await response.data
|
merchList.value = await response.data
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue