Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active August 6, 2021 11:36
Show Gist options
  • Save percybolmer/964a82ccac9b7af61bc5caab0603325d to your computer and use it in GitHub Desktop.
Save percybolmer/964a82ccac9b7af61bc5caab0603325d to your computer and use it in GitHub Desktop.
A function that wraps our gRPC request and adds metadata for JWT
export function GetUser(client, callback) {
var user = JSON.parse(localStorage.getItem('user'));
var userRequest = new UserRequest();
if (user !== null) {
userRequest.setId(user.id);
var metadata = { "x-user-auth-token": user.token, "x-user-auth-id": user.id, }
client.getUser(userRequest, metadata, callback);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment