mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
fix(frontend/Blog) fix compatibility with new backend
This commit is contained in:
3 files changed
+42
-46
No files matched your search
@@ -1,19 +1,9 @@
|
||||
import { Result } from '@/app/public/type/Result';
|
||||
|
||||
export default async function fetch_posts_list(): Promise<Result<JSON[], Error>> {
|
||||
const response = await fetch(`${ process.env.BLOG_ENDPOINT }/posts/idx.json`);
|
||||
export default async function fetch_posts_list(): Promise<any> {
|
||||
const response = await fetch(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post_list`);
|
||||
if (!response.ok) {
|
||||
return {
|
||||
ok: false,
|
||||
error: new Error(response.statusText)
|
||||
};
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
const res = await response.json();
|
||||
const posts = res['idx'].filter((posts: { type: string }) => posts.type === 'md');
|
||||
return {
|
||||
ok: true,
|
||||
value: posts
|
||||
};
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user