'use client'; // required if using next 13 app router + client component import { useEffect, useState } from 'react'; import axios from 'axios'; import Link from 'next/link'; const Blog = () => { const [blogs, setBlogs] = useState([]); const [loading, setLoading] = useState(true); const projectId = "Metatroncubesolution" useEffect(() => { const fetchBlogs = async () => { try { const res = await axios.get( `http://localhost:3010/api/blog?projectId=${projectId}` ); setBlogs(res.data.blogs); } catch (err) { console.error(err); } finally { setLoading(false); } }; if (projectId) fetchBlogs(); }, [projectId]); if (loading) return

Loading...

; return (

Blogs

{/* Create New Blog */}
+
Create New Blog
{/* Blog list from API */} {blogs.map((blog: any) => (
{blog.title}
{blog.title}

]+>/g, "").slice(0, 100) + (blog.description.length > 100 ? "..." : ""), }} />

Read More
))}
); }; export default Blog;