diff --git a/src/api/axiosConfig.js b/src/api/axiosConfig.js index bd45cb2..15de38b 100644 --- a/src/api/axiosConfig.js +++ b/src/api/axiosConfig.js @@ -1,7 +1,8 @@ import axios from "axios" import { isHyperlink } from '@/lib/isHyperlink' -const BASE_URL = process.env.DOTNET_SERVER_URL +// Define the base URL for backend API +const BASE_URL = 'http://localhost:5000'; const AXIOS_BASE = axios.create({ baseURL: BASE_URL, diff --git a/src/api/postsApi.js b/src/api/postsApi.js index 54f8964..cbe362d 100644 --- a/src/api/postsApi.js +++ b/src/api/postsApi.js @@ -21,3 +21,15 @@ export const getPost = (postSlug) => { return {} } } + + +export const createPost = async (postData) => { + try { + const response = await API.post('/posts', postData); + return response.data; + } catch (error) { + console.error('Error creating post:', error.response?.data || error.message); + throw error; + } +} + diff --git a/src/pages/posts/index.jsx b/src/pages/posts/index.jsx index c0daf46..a298bc4 100644 --- a/src/pages/posts/index.jsx +++ b/src/pages/posts/index.jsx @@ -1,9 +1,9 @@ import Head from 'next/head' - +import Link from 'next/link' import { Card } from '@/components/Card' import { SimpleLayout } from '@/components/SimpleLayout' import { formatDate } from '@/lib/formatDate' -import { getPosts, getPost } from "@/api/postsApi" +import { getPosts } from "@/api/postsApi" function Post({ post }) { const date = new Date(post.createdDate) @@ -50,6 +50,14 @@ export default function PostsIndex({ posts }) { title="Writing on software design, company building, and the aerospace industry." intro="All of my long-form thoughts on programming, leadership, product design, and more, collected in chronological order." > + + {/* Link to create a new post */} +