Open platput opened 4 years ago
You are most likely missing a step to compile your .js files before using them. See https://github.com/grpc/grpc-web/tree/master/net/grpc/gateway/examples/helloworld#compile-the-client-javascript-code.
I don't see any such build steps. I am using nuxt and in dev mod the only command I have to run is npm run dev
. So I don't get which step I am missing sadly.
Sorry I don't know what nuxtjs does. But you may want to follow our helloworld example to see if you can bring up an end-to-end example that way, and then see what you are missing.
In the part where you compile the proto files to js, you need to specify the commonjs_strict style. For example,
protoc -I=../proto hello.proto --js_out=import_style=commonjs_strict:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.
Did that. But now it shows this error: "Cannot read property 'deserializeBinary' of undefined"
I think something is not right with the code generated when using a package name.
I removed the package line in the proto file and added
option java_package = "com.example";
For the record, the code generated was proto.helloworld.HelloReply.deserializeBinary
but somehow there is an additional level of nesting. The function is proto.helloworld.helloworld.HelloReply.deserializeBinary
which does not seem to be intended.
I think line 19 of the helloworld_grpc_web_pb.js should just be
proto = require('./helloworld_pb.js');
Btw, there seems to be other issues with protobuf, commonjs_strict and package names.
I am currently also looking into setting up grpc-web
with a nuxt
/vue
/typescript
application.
Any updates?
Hello, I am trying to run grpc-web with nuxtjs. The issue I am facing only happens when I run "
npm run dev
". Its not happening if I run "npm run build
andnpm run start
" ie, production mode.I have included all the files and when I run it and try to access the webpage, it shows this error "proto is not defined." This error is coming from the generated proto files by the protoc command.
Could anyone point me in the right direction to solve this issue?