Giter Site home page Giter Site logo

Comments (5)

ayd0gdu avatar ayd0gdu commented on August 14, 2024

These are my codes:

import React from "react";
import styles from "./categoryList.module.css";
import Link from "next/link";
import Image from "next/image";

const getData = async () => {
  const res = await fetch("http://localhost:3000/api/categories", {
    cache: "no-store",
  });

  if (!res.ok) {
    throw new Error("Failed");
  }

  return res.json();
};

const CategoryList = async () => {
  const data = await getData();
  return (
    <div className={styles.container}>
      <h1 className={styles.title}>Popular Categories</h1>
      <div className={styles.categories}>
        {data?.map((item) => (
          <Link
            href={"/blog?cat=style"}
            className={`${styles.category} ${styles[item.slug]}`}
            key={item._id}
          >
            {item.img && (
              <Image
                src={item.img}
                alt=""
                width={32}
                height={32}
                className={styles.image}
              />
            )}
            {item.title}
          </Link>
        ))}
      </div>
    </div>
  );
};

export default CategoryList;

from next-blog.

allanmathenge avatar allanmathenge commented on August 14, 2024

Look at the categories route.js, the problem is in fetching and passing that data. For example your category request should be ### const categories = await prisma.category.findMany();

from next-blog.

shantanuchavhan avatar shantanuchavhan commented on August 14, 2024

Look at the categories route.js, the problem is in fetching and passing that data. For example your category request should be ### const categories = await prisma.category.findMany();

hii i am gettig empty prisma value

from next-blog.

Bdisha123 avatar Bdisha123 commented on August 14, 2024

Look at the categories route.js, the problem is in fetching and passing that data. For example your category request should be ### const categories = await prisma.category.findMany();

hii i am gettig empty prisma value

same...have you found any solution?

from next-blog.

starlove54 avatar starlove54 commented on August 14, 2024

This may happen if you dont receive any data from db incase you deployed on the server make sure to enter you server ip address in network access of mongodb, if not then you need to put your current ip address in network access of mongodb to receive data, or you could go with the option of any ( doesn't matter the ip address; you will recieve data but it is a security risk so change it to server ip address after deployment),

from next-blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.