import React, {useState} from 'react' import Head from 'next/head' import Link from 'next/link' import Card from '~/components/card' import styles from './style.module.css' Category.getInitialProps = async function({ctx: {axios, query: {slug}}}){ const {data: category} = await axios.get(`/api/categories/by-slug/${slug}`) console.log(category) if(!category) { const err = new Error("Not found") err.status = 404 throw err; } return {category} } export default function Category({category: {items, children, parent, ...category}}){ return ( <>
{category.description}
{children.length > 0 &&No items found
}