Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

serverFnCallingServerFn.ts

39 lines790 Bytes

1import { createServerFn } from '@tanstack/solid-start'
2​
3const postServerFn = createServerFn({ method: 'POST' }).handler(
4 ({ method }) => {
5 return {
6 method,
7 }
8 },
9)
10​
11const getServerFn = createServerFn({ method: 'GET' }).handler(({ method }) => {
12 return {
13 method,
14 }
15})
16​
17export const getServerFnCallingPost = createServerFn({ method: 'GET' }).handler(
18 async ({ method }) => {
19 const innerFnResult = await postServerFn({})
20​
21 return {
22 name: 'getServerFnCallingPost',
23 method,
24 innerFnResult,
25 }
26 },
28​
29export const postServerFnCallingGet = createServerFn({
30 method: 'POST',
31}).handler(async ({ method }) => {
32 const innerFnResult = await getServerFn({})
33​
34 return {
35 name: 'postServerFnCallingGet',
36 method,
37 innerFnResult,
38 }
39})