|
@@ -0,0 +1,28 @@
|
|
|
+const grpc = require('grpc');
|
|
|
+const protoLoader = require('@grpc/proto-loader');
|
|
|
+
|
|
|
+// Load the gRPC service definition
|
|
|
+const packageDefinition = protoLoader.loadSync('C:/Users/esenz/dev/Task/Fis-SearchUtility/test/hero.proto');
|
|
|
+const protoDescriptor = grpc.loadPackageDefinition(packageDefinition);
|
|
|
+
|
|
|
+// Create a gRPC client instance
|
|
|
+const heroServiceClient = new protoDescriptor.hero.HeroService(
|
|
|
+ 'http://192.168.100.32:3001/', // Replace with your server address and port
|
|
|
+ grpc.credentials.createInsecure()
|
|
|
+);
|
|
|
+
|
|
|
+// Create the gRPC request object
|
|
|
+const request = {
|
|
|
+ id: 1, // Replace with the desired hero ID
|
|
|
+};
|
|
|
+
|
|
|
+// Send the gRPC request
|
|
|
+heroServiceClient.FindOne(request, (error, response) => {
|
|
|
+ if (error) {
|
|
|
+ console.error('Error:', error);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Handle the response
|
|
|
+ console.log('Response:', response);
|
|
|
+});
|