Server Component Example

Vovk.ts client can also be used in a Server Component. To do so, you need to define "prefix" option that indicates absolute URL to the root API endpoint that overrides default relative URL.

Hello world!
BasicController.ts
ServerComponentExample.tsx
vovk.config.js
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}