Last active
June 20, 2021 19:26
-
-
Save aatifbandey/26fbc4d88073dcfeec347c3772864e59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var init = function(){ | |
const grpc = require('@grpc/grpc-js'); | |
const protoLoader = require('@grpc/proto-loader'); | |
const PROTO_PATH = __dirname +'/salary.proto'; | |
const packageDefinition = protoLoader.loadSync( | |
PROTO_PATH, { | |
keepCase: true, | |
longs: String, | |
enums: String, | |
defaults: true, | |
oneofs: true, | |
}); | |
const paymentProto = grpc.loadPackageDefinition(packageDefinition).employee; | |
function main() { | |
// Establish connection with the server | |
const client = new paymentProto.Employee('X.X.X.X:XXXX', grpc.credentials.createInsecure()); | |
let employeeIdList = [1,2,3]; | |
client.paySalary({employeeIdList: employeeIdList} , function(err, response) { | |
console.log('Data:', response); // API response | |
console.log(err); | |
}); | |
} | |
main(); | |
} | |
exports.init = init; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment