Skip to main content

Client

SOVLOOKUPLess than 1 minuteGuideclient

Tips

We'll walk through the code line by line, so you can focus on only the highlighted portion.

First, you need to introduce metapoint and server's meta.

import { peer } from "metapoint";
import type { Meta } from "./server";
const node = await peer();
const channel = await node.connect<Meta>("your server addr");
const helloworld = await channel("helloworld");
console.log(await helloworld("sovlookup")); // ["hi sovlookup", "hello world!"]
 
 




What's meta?

  • Meta is usually exported on the server side as a type definition.

  • Meta is a typescript type definition that contains all callable functions on the server side and their signatures.

  • Meta enables you to write client-side code with type hints and autocompletion.

Then, start a metapoint local node(client) and connect to the remote node(server).

import { peer } from "metapoint";
import type { Meta } from "./server";
const node = await peer();
const channel = await node.connect<Meta>("your server addr");
const helloworld = await channel("helloworld");
console.log(await helloworld("sovlookup")); // ["hi sovlookup", "hello world!"]


 
 


Finally, select the handler that runs on the remote and use it like calling a local function!

import { peer } from "metapoint";
import type { Meta } from "./server";
const node = await peer();
const channel = await node.connect<Meta>("your server addr");
const helloworld = await channel("helloworld");
console.log(await helloworld("sovlookup")); // ["hi sovlookup", "hello world!"]