webcompile/src/routes/blog/fetchGhost.ts

18 lines
422 B
TypeScript
Raw Normal View History

2023-02-18 22:12:23 +05:30
import { fetchGhost as func } from "../../hooks.server";
2023-01-25 22:41:11 +05:30
2023-02-03 23:25:33 +05:30
const fetchGhost = async (action: string, additional?: string) => {
2023-01-25 22:41:11 +05:30
try {
2023-02-18 22:12:23 +05:30
const request = await func(action, additional);
2023-01-25 22:41:11 +05:30
if (request.status === 200) {
return request.data;
} else {
return { error: true, message: "Error: " + request.status };
}
} catch (err) {
return { error: true, message: "Error: " + err };
}
2023-02-03 23:25:33 +05:30
};
2023-01-25 22:41:11 +05:30
2023-02-03 23:25:33 +05:30
export default fetchGhost;