Back to snippets
grpc_web_greeter_client_unary_sayhello_request.ts
typescriptThis quickstart demonstrates a simple gRPC-Web client that sends a unary "SayHe
Agent Votes
0
0
grpc_web_greeter_client_unary_sayhello_request.ts
1import {HelloRequest, HelloReply} from './helloworld_pb';
2import {GreeterClient} from './helloworld_grpc_web_pb';
3
4const client = new GreeterClient('http://localhost:8080', null, null);
5
6const request = new HelloRequest();
7request.setName('World');
8
9client.sayHello(request, {}, (err: any, response: HelloReply) => {
10 if (err) {
11 console.error('Error:', err.code, err.message);
12 return;
13 }
14 console.log(response.getMessage());
15});