export function collector(id: string, url: string, type: 'spark' | 'timings') {
if (!url) return;
return fetch(url + '/' + type, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id }),
}).catch(error => {
console.error('Fetch error:', error);
return Promise.reject(error);
});
}
export const useResults = routeLoader$(async ({ params }) => {
try {
await collector(params.id, 'https://api.url.com', 'spark');
} catch (error) {
console.error('Collector error:', error);
}
return await analyzeProfile(params.id);
});
export default component$(() => {
const results = useResults();
return(...);
}