Comments (2)
The result is empty because it returns a Promise, not the actual result. You can try something like this.
public getBook(): Promise<any> {
const getBookRequest = new GetBookRequest();
getBookRequest.setIsbn(60929871);
const requestPromise = new Promise<any>((resolve, reject) => {
grpc.unary(BookService.GetBook, {
request: getBookRequest,
host: host,
onEnd: (res) => {
const {status, statusMessage, headers, message, trailers} = res;
if (status === Code.OK && message) {
console.log("getBook.onEnd.message", message.toObject());
resolve(message.toObject());
}
},
});
});
return requestPromise;
}
If you are calling getBook from another function, you can get result like this way
public async someFunction(): Promise<any> {
book: any = await getBook();
// do binding here
...
}
Or
getBook().then(function(result) {
book: any = result;
// do binding here
...
});
from grpc-web.
Thanks a lot @joenayjoe. That got me past that sticking point. I'm rendering my results on a browser now.
from grpc-web.
Related Issues (20)
- Implement the http.RoundTripper interface? HOT 2
- Detach IsGrpcWebRequest and IsGrpcWebSocketRequest from WrappedGrpcServer HOT 2
- grpcwebproxy websocket connection fails with specific origin HOT 2
- QUIC and HTTP3 support HOT 1
- Status codes and error messages are displayed incorrectly on the angular client. HOT 4
- Golang Grpc Web Server UnaryInterceptor is not triggered by grpc-web Client HOT 1
- Get client stream method return HOT 3
- ReferenceError: self is not defined when trying to call a grpc-web function from a CLI/server application HOT 3
- grpcwebproxy - Help Proxying existing GRPC service HOT 1
- Add support of bufbuild/protobuf-es HOT 3
- Changing route to the root of the host HOT 1
- Lack of grpc Trailers-Only support in the wrapHandler function
- Is there any way to use Nginx or Envoy with this project? HOT 1
- Question: What is the status of `go/grpcwebproxy` project? HOT 3
- grpc-web: Importing as ESModule in Node HOT 1
- grpcwebproxy `--allowed_headers` param is case-sensitive for WebSocket
- Grpc client unexpected behavior HOT 1
- Project status
- grpc-web. `Response closed without headers` but no way to get the status code.
- grpcwebproxy: 400 bad request on websocket connection attempts HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-web.