如何使用 ServiceStack 访问响应 Headers

How do I access the Response Headers using ServiceStack

我正在使用 React with Redux 工具包,但我无法访问 Response headers

return await client
.get(new Users())
.then((data) => {

// how to I access the Response Header here?
  console.log("data", data);
  return data;
})
.catch((error) => {

});

我假设您指的是 ServiceStack's TypeScript Service Client, the public API of which you can find on index.d.ts,您可以在其中使用实例 requestFilterresponseFilter:

export declare class JsonServiceClient {
    //...
    requestFilter: (req: IRequestInit) => void;
    responseFilter: (res: Response) => void;
}

检查底层 W3C fetch API's Request / Response,例如:

let client = new JsonServiceClient();
client.responseFilter = function(r) {
    console.log(r.headers)
}

client.get(new Users())
    .then(...)