grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

How to set array with grpc-web

Open Juken8104 opened this issue 6 years ago • 1 comments

hi, the proto file is as follow

message TestDetailInfo {
  int32 testone = 1;
  double testtwo = 2;
}
message CreateTest {
  string test_name =1
  repeated TestlDetailInfo test_detail_info = 2;
}
message NilRsp {
}
service TestService {
    rpc CreateData(CreateTest) returns (NilRsp) {};
  }

the js is as follow

let TestClient= new TestServiceClient("http://localhost")
let testparams={
    testName:"test001",
    testDetailInfo:[
        {
            "testone":"111",
            "testtwo":2
        }
    ]
};
let params= new CreateTest()
params.setTestName(testparams.testName);
params.setTestDetailInfo(testparams.testDetailInfo)
const call = TestClient.createData(params,metadata,
    (err, response) => {
        if(err == null){

        }else{

        }
    });

and there is an error shows:

TypeError: c[e].toArray is not a function

https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#repeated how to format the specified JavaScript array?

Juken8104 avatar Jan 01 '20 15:01 Juken8104

hi, have you resolve it? I have a same problem. https://github.com/grpc/grpc-web/issues/739

Silvia813 avatar Feb 26 '20 06:02 Silvia813