SolidJSS
SolidJSโ€ข3y agoโ€ข
9 replies
haikesikejiqiang

How should I use createRouteData

export function routeData({ params, location }: RouteDataArgs) {
    return createServerData$(
        async ([slug, page]) => {
            const response = await fetch(`/api/list`, {
                method: "POST",
                body: JSON.stringify({
                    keyword: slug,
                    page: page
                })
            });
            return (await response.json());
        },
        { key: () => [params.slug, location.query['page'] || "1"] }
    );
}

How to request the internal API must write the full URL such as http://localhost:3000/api/list
1690016383790.png
Was this page helpful?