fix(frontend/blog/post) fix compatibility with new backend

- switch to axios
This commit is contained in:
lumither committed 2024-05-04 22:54:38 +08:00
1 parent 4f09648a34
commit a4d0b7140a
4 files changed
+24 -11

No files matched your search

+5 -3
View File
@@ -1,9 +1,11 @@
import axios from 'axios';
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) {
const response = await axios(`http://localhost:${ process.env.BACKEND_PORT }/api/get/post_list`);
if (response.status !== 200) {
throw new Error(response.statusText);
}
return await response.json();
return response.data;
}