Last active
April 26, 2019 15:06
-
-
Save mohak1712/a392673c1b8db46623ecb9255c547c40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import logo from './logo.svg'; | |
import './App.css'; | |
const { PingPongServiceClient } = require('./ping_pong_grpc_web_pb'); | |
const { PingRequest, PongResponse } = require('./ping_pong_pb.js'); | |
var client = new PingPongServiceClient('http://localhost:9090', null, null); | |
class App extends Component { | |
callGrpcService = () => { | |
const request = new PingRequest(); | |
request.setPing('Ping'); | |
client.pingPong(request, {}, (err, response) => { | |
if (response == null) { | |
console.log(err) | |
}else { | |
console.log(response.getPong()) | |
} | |
}); | |
} | |
render() { | |
return ( | |
<div className="App"> | |
<header className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<button style={{padding:10}} onClick={this.callGrpcService}>Click for grpc request</button> | |
</header> | |
</div> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment