Skip to content

Commit

Permalink
Try solution by mvonwaldner
Browse files Browse the repository at this point in the history
  • Loading branch information
boldt committed Nov 16, 2023
1 parent 46fb593 commit d0c8915
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import { useEffect, useState } from 'react';
import './App.css';
import { EchoServiceClient } from './grpc/EchoServiceClientPb';
import { EchoRequest } from './grpc/echo_pb';
const service = require('./grpc/EchoServiceClientPb');


function App() {

const [echoResponse, setEchoResponse] = useState<EchoRequest.AsObject | undefined>(undefined);
const [echoResponse, setEchoResponse] = useState<string | undefined>(undefined);

useEffect(() => {
var echoService = new EchoServiceClient('http://localhost:8080');

var request = new EchoRequest();
var request = new service.EchoRequest();
request.setMessage('Hello World!');

echoService.echo(request, {}, function(err, response) {
if(!err) setEchoResponse(response.toObject());
if(!err) setEchoResponse(response.toObject().message);
});

}, []);
Expand All @@ -23,7 +24,7 @@ function App() {
<div className="App">
<header className="App-header">
<p>
Response: {echoResponse ? echoResponse.message : "No response yet!"}
Response: {echoResponse ? echoResponse : "No response yet!"}
</p>
</header>
</div>
Expand Down

0 comments on commit d0c8915

Please sign in to comment.