import { notFound } from '@tanstack/solid-router' import axios from 'redaxios' export type PostType = { id: string title: string body: string } const queryURL = 'https://jsonplaceholder.typicode.com' export const fetchPost = async (postId: string) => { console.info(`Fetching post with id ${postId}...`) const post = await axios .get(`${queryURL}/posts/${postId}`) .then((r) => r.data) .catch((err) => { if (err.status === 404) { throw notFound() } throw err }) return post } export const fetchPosts = async () => { console.info('Fetching posts...') return axios .get>(`${queryURL}/posts`) .then((r) => r.data.slice(0, 10)) }