Consuming external API with TRPC.

Hi so I have created this TRPC query that consumes an api from a node server:
export const leadsRouter = createTRPCRouter({
getAllLeads: privateProcedure.query(async () => {
const response = await axios.get(LEADS_BASE_URL + "api/leads/all");
console.log("response", response);
return response.data;
}),
});
export const leadsRouter = createTRPCRouter({
getAllLeads: privateProcedure.query(async () => {
const response = await axios.get(LEADS_BASE_URL + "api/leads/all");
console.log("response", response);
return response.data;
}),
});
But it's not fetching anything, any idea what I might have missed?
2 Replies
eyeino
eyeino2y ago
Does hitting it with curl or postman return anything?
josh-dev627
josh-dev627OP2y ago
Sorry there was an error on my end. Although I can't still figure out how to do this using client-side fetching this only works when I query it through trpc but using react-query useQuery, won't allow me to query an external api or atleast there is something that I missed
Want results from more Discord servers?
Add your server