Commit 75212d09 authored by Dannon Baker's avatar Dannon Baker
Browse files

Swap datatypes info request to fetch client

parent 5cb524c5
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
import axios from "axios";

import { GalaxyApi } from "@/api";
import type { components } from "@/api";
import { withPrefix } from "@/utils/redirect";
import { rethrowSimple } from "@/utils/simple-error";

export type CompositeFileInfo = components["schemas"]["CompositeFileInfo"];
@@ -10,10 +8,18 @@ export type DatatypeDetails = components["schemas"]["DatatypeDetails"];
/**
 * Get details about a specific datatype
 */
export async function fetchDatatypeDetails(extension: string) {
export async function fetchDatatypeDetails(extension: string): Promise<DatatypeDetails> {
    try {
        const { data } = await axios.get(withPrefix(`/api/datatypes/${extension}`));
        return data;
        const { GET } = GalaxyApi();
        const { data } = await GET("/api/datatypes/{datatype}", {
            params: {
                path: { datatype: extension },
            },
        });
        if (!data) {
            throw new Error(`Failed to fetch datatype details for ${extension}`);
        }
        return data as DatatypeDetails;
    } catch (error) {
        rethrowSimple(error);
    }