Basic usage of Vovk Controller.
1import { get, prefix } from 'vovk';
2
3@prefix('basic')
4export default class BasicController {
5 /**
6 * Return a greeting
7 */
8 @get('greeting', { cors: true })
9 static getHello() {
10 return { greeting: 'Hello world!' };
11 }
12}
1import { get, prefix } from 'vovk';
2
3@prefix('basic')
4export default class BasicController {
5 /**
6 * Return a greeting
7 */
8 @get('greeting', { cors: true })
9 static getHello() {
10 return { greeting: 'Hello world!' };
11 }
12}
1import { get, prefix } from 'vovk';
2
3@prefix('basic')
4export default class BasicController {
5 /**
6 * Return a greeting
7 */
8 @get('greeting', { cors: true })
9 static getHello() {
10 return { greeting: 'Hello world!' };
11 }
12}
1import { get, prefix } from 'vovk';
2
3@prefix('basic')
4export default class BasicController {
5 /**
6 * Return a greeting
7 */
8 @get('greeting', { cors: true })
9 static getHello() {
10 return { greeting: 'Hello world!' };
11 }
12}
1'use client';
2import { useState } from 'react';
3import { BasicController } from 'vovk-client';
4import type { VovkReturnType } from 'vovk';
5
6export default function BasicExample() {
7 const [serverResponse, setServerResponse] = useState<VovkReturnType<typeof BasicController.getHello>>();
8
9 return (
10 <>
11 <button
12 onClick={async () => {
13 setServerResponse(await BasicController.getHello());
14 }}
15 >
16 Get Greeting from Server
17 </button>
18 <div>{serverResponse?.greeting}</div>
19 </>
20 );
21}
1'use client';
2import { useState } from 'react';
3import { BasicController } from 'vovk-client';
4import type { VovkReturnType } from 'vovk';
5
6export default function BasicExample() {
7 const [serverResponse, setServerResponse] = useState<VovkReturnType<typeof BasicController.getHello>>();
8
9 return (
10 <>
11 <button
12 onClick={async () => {
13 setServerResponse(await BasicController.getHello());
14 }}
15 >
16 Get Greeting from Server
17 </button>
18 <div>{serverResponse?.greeting}</div>
19 </>
20 );
21}
1'use client';
2import { useState } from 'react';
3import { BasicController } from 'vovk-client';
4import type { VovkReturnType } from 'vovk';
5
6export default function BasicExample() {
7 const [serverResponse, setServerResponse] = useState<VovkReturnType<typeof BasicController.getHello>>();
8
9 return (
10 <>
11 <button
12 onClick={async () => {
13 setServerResponse(await BasicController.getHello());
14 }}
15 >
16 Get Greeting from Server
17 </button>
18 <div>{serverResponse?.greeting}</div>
19 </>
20 );
21}
1'use client';
2import { useState } from 'react';
3import { BasicController } from 'vovk-client';
4import type { VovkReturnType } from 'vovk';
5
6export default function BasicExample() {
7 const [serverResponse, setServerResponse] = useState<VovkReturnType<typeof BasicController.getHello>>();
8
9 return (
10 <>
11 <button
12 onClick={async () => {
13 setServerResponse(await BasicController.getHello());
14 }}
15 >
16 Get Greeting from Server
17 </button>
18 <div>{serverResponse?.greeting}</div>
19 </>
20 );
21}