Created
October 24, 2018 16:43
-
-
Save lucperkins/db2898fba6cd3ed7ab82bd70153927c0 to your computer and use it in GitHub Desktop.
This file contains 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
const {GetTodoRequest} = require(‘./todos_pb.js’); | |
const {TodoServiceClient} = require(‘./todos_grpc_web_pb.js’); | |
const todoService = new proto.todos.TodoServiceClient(‘http://localhost:8080’); | |
const todoId = 1234; | |
var getTodoRequest = new proto.todos.GetTodoRequest(); | |
getTodoRequest.setId(todoId); | |
var metadata = {}; | |
var getTodo = todoService.getTodoById(getTodoRequest, metadata, (err, response) => { | |
if (err) { | |
console.log(err); | |
} else { | |
const todo = response.todo(); | |
if (todo == null) { | |
console.log(`A TODO with the ID ${todoId} wasn’t found`); | |
} else { | |
console.log(`Fetched TODO with ID ${todoId}: ${todo.content()}`); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment