Uncaught TypeError: o.toArray is not a function
See original GitHub issueHi!
I try to work with any.proto
syntax = "proto3";
import "google/protobuf/any.proto";
...
message AddJobRequest {
string api_key = 1;
int32 token_id = 2;
JobAction action = 3;
google.protobuf.Any payload = 4;
}
I compile proto under Windows with command
protoc --plugin=protoc-gen-grpc-web=protoc-gen-grpc-web-1.0.3-windows-x86_64.exe --grpc-web_out=out=Job_grpc_web_pb.js,import_style=commonjs,mode=grpcweb:JS_Campaigns Job.proto
and pack with
npx webpack client.js
My function is:
function addNewJob(api_key, token_id, action, payload, callback) {
var request = new AddJobRequest();
request.setApiKey(api_key);
request.setTokenId(token_id);
request.setAction(action);
request.setPayload({ payload: payload });
job_client.addNew(request, metadata, (err, response) => {
callback(response, err);
});
}
I receive error
Uncaught TypeError: o.toArray is not a function
The same error occurs with google/protobuf/wrappers.proto What I’m doing wrong?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
javascript - .toArray(); is not a function - Stack Overflow
The issue is you have to create a new marker. If you follow the code in the documentation it should work. Try the...
Read more >How to solve 'TypeError: db.find(…).toArray is not a function' in ...
The toArray function exists on the Cursor class from the Native MongoDB NodeJS driver. The find method in MongooseJS returns a Query object....
Read more >TypeError error: _toArray is not a function. - GSAP - GreenSock
I tried to make this slide in Rickett to learn: I get a TypeError error: _toArray is not a function.
Read more >this.get(...).toArray is not a function(…)-ember.js - appsloveworld
Coding example for the question Uncaught TypeError: this.get(. ... You're not alone in struggling with this, as I've been seeing a large number...
Read more >TypeError: find is not a function in JavaScript | bobbyhadz
The "find is not a function" error occurs when we call the find() method on a value that is not of type array....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It’s difficult to tell why you have “proto” as undefined without looking at all your “client.js” script. For my part, just by following the basic “helloworld” example, I got this “proto” variable in my globals.
If it could help you : I was able to get some inspiration by looking at this example. Though I didn’t follow the example step by step, it was by looking at it that I discoved that there was a “fromJavaScript” function (and also a “toJavaScript”) to convert JSON to Struct.proto (and vice-versa).
Sorry I have to declare Bug Bankruptcy on some of these older bugs. But this looks like a protobuf issue. If this is still a grpc-web issue, please open a new one.