devve2kcc
devve2kcc
Explore posts from servers
TTCTheo's Typesafe Cult
Created by devve2kcc on 1/27/2025 in #questions
Next js server actions
Hi, its my first time using server actions, i always use an api and make requests using react query, So I'm used to handling query invalidations, through react query, and now using actions, to simplify my code base, since it's a very simple project, would this be the best way to update data after removing files? by the way, does the code structure look correct?
2 replies
HHono
Created by devve2kcc on 1/16/2025 in #help
Problem passing jwt token by rpc
hi guys, i have an endpoint localhost:5555/api/summary, that works fine testing on any app like postman, passing an Bearer token, but do not work when i use hono client passing the bearer token, always says that the token is not passed
const app = new Hono().get("/", async (c) => {
const user = c.get("jwtPayload");

if (!user) {
return c.json({ error: "Unauthorized" }, 401);
}

return c.json({success: true})
const app = new Hono().get("/", async (c) => {
const user = c.get("jwtPayload");

if (!user) {
return c.json({ error: "Unauthorized" }, 401);
}

return c.json({success: true})
export const useGetSummary = () => {
const { user } = useUser()
const query = useQuery({
queryKey: ["summary"],
queryFn: async () => {
const token = user?.token
console.log(token); // the token exists, because is primted on console.

const response = await client.api.summary.$get({
headers: {
Authorization: `Bearer ${token}` //im passing there the bearer token
}
});

if (!response.ok) {
throw new Error("Failed to fetch transactions!");
}

const { data } = await response.json();
return {
...data,
incomeAmount: convertAmountFromMiliunits(data.incomeAmount),
expensesAmount: convertAmountFromMiliunits(data.expensesAmount),
remainingAmount: convertAmountFromMiliunits(data.remainingAmount),
categories: data.categories.map((category) => ({
...category,
value: convertAmountFromMiliunits(category.value),
})),
days: data.days.map((day) => ({
...day,
income: convertAmountFromMiliunits(day.income),
expenses: convertAmountFromMiliunits(day.expenses),
})),
};
},
});
return query;
};
export const useGetSummary = () => {
const { user } = useUser()
const query = useQuery({
queryKey: ["summary"],
queryFn: async () => {
const token = user?.token
console.log(token); // the token exists, because is primted on console.

const response = await client.api.summary.$get({
headers: {
Authorization: `Bearer ${token}` //im passing there the bearer token
}
});

if (!response.ok) {
throw new Error("Failed to fetch transactions!");
}

const { data } = await response.json();
return {
...data,
incomeAmount: convertAmountFromMiliunits(data.incomeAmount),
expensesAmount: convertAmountFromMiliunits(data.expensesAmount),
remainingAmount: convertAmountFromMiliunits(data.remainingAmount),
categories: data.categories.map((category) => ({
...category,
value: convertAmountFromMiliunits(category.value),
})),
days: data.days.map((day) => ({
...day,
income: convertAmountFromMiliunits(day.income),
expenses: convertAmountFromMiliunits(day.expenses),
})),
};
},
});
return query;
};
6 replies