grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.46k stars 762 forks source link

Missing metadata trailer values on ReactJS + Typescript #1304

Closed mconrejas closed 1 year ago

mconrejas commented 1 year ago

Can anyone please enlighten me why this code:

const metadata = {
  authorization: "Bearer ${jwtToken}`,
  "grpc-metadata-loginkey": `${loginKey}`
};

const req = new StockRequest();

req.setTicker(`${symbol}-${exchangeCode}`);

let stream;

stream = client.getPriceTicks(req, metadata);

stream.on('metadata', function (metadata) {
  console.log('metadata', metadata);
});

Is only showing this: Screenshot from 2022-11-21 15-42-52

when the stream returns a 401 on a ReactJS + Typescript project?

While it's showing this: Screenshot from 2022-11-21 18-38-09

on a pure javascript project using the same set of codes.

My goal here is to show a custom error message included on the metadata trailers when the stream returns a 401.

sampajano commented 1 year ago

Hi,

Could you clarify on what metadata you're expecting and why?

From the error, it seems like your got a 401 error with a detailed error-message indicating a login error. Would it be sufficient for your to proceed?

thanks :)

sampajano commented 1 year ago

Hi. I'm closing for now but feel free to reopen with more details. thanks!