Damian
Damian
HHono
Created by Damian on 5/21/2024 in #help
Importing AppType to client defaults output to any types
Hi, I just started using Hono yesterday and I'm loving it, but I'm facing an issue where, when I import AppType to the client, the types for output default to the Any type. I'm currently stumped on why this happens. Client src: /packages/frontend/src/lib/apis/images/index.ts
import type { AppType } from "@tavern/functions/src/stableDiffusion";
import { hc } from "hono/client";
import { Resource } from "sst";

const client = hc<AppType>(Resource.StableDiffusion.url);

export const getImageGenerationModels = async () => {
let error = "";
const res = await client.models
.$get()
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ("detail" in err) {
error = err.detail;
} else {
error = "Server connection failed";
}
return null;
});
if (error) {
throw error;
}
return res;
};
import type { AppType } from "@tavern/functions/src/stableDiffusion";
import { hc } from "hono/client";
import { Resource } from "sst";

const client = hc<AppType>(Resource.StableDiffusion.url);

export const getImageGenerationModels = async () => {
let error = "";
const res = await client.models
.$get()
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
.catch((err) => {
console.log(err);
if ("detail" in err) {
error = err.detail;
} else {
error = "Server connection failed";
}
return null;
});
if (error) {
throw error;
}
return res;
};
7 replies