fix api route

This commit is contained in:
Andreas 2025-01-15 06:01:48 +01:00
parent 5c0e3577a8
commit c992579931

View File

@ -13,11 +13,12 @@ import "@/app/index.css"
import { Post } from "@/models"; import { Post } from "@/models";
import { Attributes } from "@sequelize/core"; import { Attributes } from "@sequelize/core";
import { DeepPartial } from "@/util/deeppartial"; import { DeepPartial } from "@/util/deeppartial";
import { constructAPIUrl } from "@/util/url/urlConstructor";
async function getData(slug:string):Promise<Attributes<Post>> { async function getData(slug:string):Promise<Attributes<Post>> {
// Get all posts from the API // Get all posts from the API
const res = await fetch(`http://localhost:3000/api/post/${slug}`); const res = await fetch(await constructAPIUrl(`post/${slug}`));
// The return value is *not* serialized // The return value is *not* serialized
// You can return Date, Map, Set, etc. // You can return Date, Map, Set, etc.
// Recommendation: handle errors // Recommendation: handle errors