fix: fallaba la carga de posts

lo que pasa es que el $session?.accessToken si $session es null va a dar
undefined y eso entra interpretado como un string a el header de auth
This commit is contained in:
2026-02-05 21:29:30 -03:00
parent 52c583a039
commit 9546b6548d
5 changed files with 12 additions and 9 deletions

View File

@@ -29,6 +29,7 @@
let usu = $state({ displayName: data.displayName, bio: data.bio });
let contenido = $derived(() => {
if (data.bio == '') return '';
let t = data.bio
.replaceAll('&', '')
.replaceAll('<', '')
@@ -134,7 +135,7 @@
</h1>
{#if data.bio}
<p class="mt-4 rounded-4xl bg-accent p-4 text-center text-muted-foreground">
{@html usu.bio.replaceAll('\n', '<br>')}
{@html contenido()}
</p>
{/if}
{/if}

View File

@@ -16,7 +16,7 @@ export async function obtenerPostPorId(
const req = await fetchFn(`${get(apiBase)}/api/posts/${idpost}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
Authorization: `Bearer ${get(sesionStore)?.accessToken || ''}`
}
});
let data = await req.json();

View File

@@ -15,7 +15,7 @@ export async function obtenerRespuestasPorId(
const req = await fetchFn(`${get(apiBase)}/api/posts/${id}/replies?page=${page}`, {
method: 'GET',
headers: {
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
Authorization: `Bearer ${get(sesionStore)?.accessToken || ''}`
}
});
if (req.ok) {

View File

@@ -54,7 +54,7 @@
`${$apiBase}/api/posts/user/${params.perfil}?page=${pageNumber}&pageSize=20`,
{
headers: {
Authorization: `Bearer ${$sesionStore?.accessToken}`
Authorization: `Bearer ${$sesionStore?.accessToken || ''}`
}
}
);

View File

@@ -103,10 +103,12 @@
</Content>
</Card>
{/if}
<div class="my-4">
<Separator></Separator>
</div>
<CrearPost placeholder={`Responder a @${data.post.authorName}`} parentPostId={data.post.id} />
{#if $sesionStore}
<div class="my-4">
<Separator></Separator>
</div>
<CrearPost placeholder={`Responder a @${data.post.authorName}`} parentPostId={data.post.id} />
{/if}
<div class="my-4">
<Separator></Separator>
@@ -211,8 +213,8 @@
</TooltipTrigger>
<TooltipContent>Borrar</TooltipContent>
</Tooltip>
<BotonSeguir {post} variant="icon-sm" />
{/if}
<BotonSeguir {post} variant="icon-sm" />
</div>
</div>
<p class=" mt-1 line-clamp-2 rounded-md p-2 text-lg">