mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-18 15:57:31 -03:00
fix: no se usaba el fetch del framework
This commit is contained in:
@@ -2,10 +2,11 @@ import { apiBase } from '@/stores/url';
|
|||||||
import { sesionStore } from '@/stores/usuario';
|
import { sesionStore } from '@/stores/usuario';
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
|
|
||||||
export async function obtenerCantidadDeUsosdeHtag(htag: string) {
|
export async function obtenerCantidadDeUsosdeHtag(htag: string, fetch2?: Function) {
|
||||||
if (!htag) return null;
|
if (!htag) return null;
|
||||||
|
const fetchFn = fetch2 || fetch;
|
||||||
try {
|
try {
|
||||||
const req = await fetch(`${get(apiBase)}/api/posts/hashtag/${htag}`, {
|
const req = await fetchFn(`${get(apiBase)}/api/posts/hashtag/${htag}`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { obtenerCantidadDeUsosdeHtag } from '@/hooks/obtenerCantidadDeUsosdeHtag.js';
|
import { obtenerCantidadDeUsosdeHtag } from '@/hooks/obtenerCantidadDeUsosdeHtag.js';
|
||||||
import { error } from '@sveltejs/kit';
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
export async function load({ params }) {
|
export async function load({ params, fetch }) {
|
||||||
let { htag } = params;
|
let { htag } = params;
|
||||||
|
|
||||||
const posts = await obtenerCantidadDeUsosdeHtag(htag);
|
const posts = await obtenerCantidadDeUsosdeHtag(htag, fetch);
|
||||||
// if (cantidad == null || posts.lenght == 0) return error(404, 'no existe el #(hashtag)');
|
// if (cantidad == null || posts.lenght == 0) return error(404, 'no existe el #(hashtag)');
|
||||||
return { htag, posts };
|
return { htag, posts };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user