I have the following protobuf definition:
service MyService {
rpc ServiceMethod (ServiceMethodRequest) returns (ServiceMethodResponse) {}
}
message ServiceMethodRequest{
string requestParam = 1;
}
message ServiceMethodResponse{
Error error = 1;
SomeObjectList data = 2;
}
message Error{
string code = 1;
string errorMessage = 2;
}
message SomeObject {
string myobject = 1;
}
message SomeObjectList {
repeated SomeObject myobjects = 1;
}
As you can see I want to return formatted response so my API has some standardized way of responding. I formatted my response like this (this is in JSON format because of readability):
{"error":{"code":"-1","errorMessage":""},"data":{"myobjects":[{"myobject":"some string"},{"myobject":"another string"}]}}
But on the client side I am constantly getting:
{ Error: 2 UNKNOWN: Unknown Error
at Object.exports.createStatusError (.../node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (.../node_modules/grpc/src/client_interceptors.js:1204:28)
at InterceptingListener._callNext (.../node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (.../node_modules/grpc/src/client_interceptors.js:618:8)
at callback (.../node_modules/grpc/src/client_interceptors.js:845:24)
code: 2,
metadata: Metadata { _internal_repr: {}, flags: 0 },
details: 'Unknown Error' }
when I try to console.log response object.
What am I doing wrong? Also, is there any good book on grpc with some examples (C, C#, Java, Python, JavaScript)? Thanks in advance!