Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
18 replies
Fervore

How do I fetch from server side with useMutation?

Hello, I'm trying to do a server side fetch from the mutations that I made in the backend of my t3 app but I'm struggling to understand some things can someone help me please? I'm trying to pass the data from both the queries as props. What would be the most optimal approach to this?

This is my code
export const getStaticProps: GetStaticProps = async ({ locale = "en" }) => {

  const sub = api.subscription.getUserPendingSubscriptions.useMutation().data;
  const history = api.changesHistory.getCurrentUserHistoryChanges.useMutation().data;

  return {
    props: {
      ...(await serverSideTranslations(locale)),
      sub,
      history
    },
  };
};

export default function Dashboard({ sub, history}) {
...
Was this page helpful?