Updated function
This commit is contained in:
parent
40f2ad04f4
commit
b19acd6343
1 changed files with 7 additions and 2 deletions
|
|
@ -2,9 +2,14 @@ import { ofetch } from 'ofetch'
|
||||||
|
|
||||||
const API = import.meta.env.VITE_BACKEND
|
const API = import.meta.env.VITE_BACKEND
|
||||||
|
|
||||||
export default async (api: string) => {
|
export default async (api: string, value?: any) => {
|
||||||
try {
|
try {
|
||||||
const fetch = await ofetch(API + api, { parseResponse: JSON.parse })
|
let fetch
|
||||||
|
if (!value) {
|
||||||
|
fetch = await ofetch(API + api, { parseResponse: JSON.parse })
|
||||||
|
} else {
|
||||||
|
fetch = await ofetch(API + `${api}/${value}`, { parseResponse: JSON.parse })
|
||||||
|
}
|
||||||
const result = fetch.result
|
const result = fetch.result
|
||||||
return result
|
return result
|
||||||
} catch {
|
} catch {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue