grpc-client-promise
v1.0.5
Published
grpc-client-promise also support Promise API. Which works very well with ES7 async await
Downloads
10
Readme
grpc-client-promise
grpc-client-promise also support Promise API. Which works very well with ES7 async await.
If you like, you can subscribe to start or watch
Installation
npm i grpc-client-promise
Usage
grpcClient.conntct(options)
- options
- ip: server ip
- port: server port
- protosPath: grpc protos folder path
- ervicesPath: grpc services folder path
- example
const client = grpcClient.conntct({ ip: '127.0.0.1', port: 8981, protosPath: './test', servicesPath: './test' });
- options
client.services.method(requestParams,[metadata])
- example
client.greeter.greet({ name: hello }).then(ret => console.log(ret)); client.greeter.greet({ name: hello }, metadata).then(ret => console.log(ret));
Demo
'use strict'
const grpcClient = require('../index');
const client = grpcClient.conntct({
ip: '127.0.0.1',
port: 8981,
protosPath: './test',
servicesPath: './test'
});
client.greeter.greet().then(ret => console.log(ret));
client.greeter.greet({ name: hello }).then(ret => console.log(ret));
const Metadata = grpc.Metadata;
const metadata = new Metadata();
metadata.set('token', '231hjkhdKJH321J4H3KJ12HKJ');
client.greeter.greet({ name: hello }, metadata).then(ret => console.log(ret));