Next.js Discord

Discord Forum

SWR issue perhaps

Unanswered
In&Out posted this in #help-forum
Open in Discord
Original message was deleted.

3 Replies

export function getSingleCoin({ticker}:{ticker:any}) {
  console.log(ticker,"bop")
  const { data, error, isLoading } = useSWR(
    `http://localhost:8000/price/${ticker}`,
    fetcher,
    { refreshInterval: 15000 } // this causes refresh
  );

  return {
    data,
    isError: error,
    isLoading,
  };
}
export default function Page({ params }: { params: any }) {
  console.log(params.ticker)
  const { data, isLoading, isError } = getSingleCoin(params.ticker);
When i print the params.ticker, i get the right one but when i print it inside getSingleCoin, i get undefined, why is that?