Skip to content
Discussion options

You must be logged in to vote

ok i figured it out by just using only useInfinitequery,

first i will fetch the data on the api/slug path and get the data from there and then pass it to the other path (IF THE DATA IS VALID)

const Get_Similar_Items = ({ myslug }) => {

  let my_data;
  let country;
  let category;
  let color;

  const {
    data,
    isLoading,
    isError,
    fetchNextPage,
    hasNextPage,
    isFetching,
  } = useInfiniteQuery({
    queryKey: ['similarproducts', myslug],
    queryFn: async ({ pageParam }) => {
      if(pageParam[0] === myslug){
        my_data = await fetch(`http://localhost:3000/api/slug/${pageParam[0]}`, { cache: 'no-store' });      
      }else{
        my_data = await fetch(`htt…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by firaki12345-cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant