chore: movi el getPosts a hooks/ y le agrege un header

This commit is contained in:
2025-12-03 15:04:31 -03:00
parent 6ac942fde0
commit 18670e62dd
2 changed files with 18 additions and 14 deletions

17
src/lib/hooks/getPosts.ts Normal file
View File

@@ -0,0 +1,17 @@
import { apiBase } from "@/stores/url";
import { sesionStore } from "@/stores/usuario";
import { get } from "svelte/store";
export async function getPosts() {
const req = await fetch(`${get(apiBase)}/timeline?pageSize=20`,{
headers: {
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
}
});
if (req.ok) {
return await req.json();
}
}