Hi,
I have a similar issue to #1156. But in my case the response is completely empty.
Here is my afterware:
apolloClient.networkInterface.useAfter([{
applyAfterware({ response }, next) {
if (process.env.NODE_ENV === 'development') {
console.log('got new response', response);
}
next();
}
}]);
Here is the real response:
Here is the console log:
BTW. I've already asked at StackOverflow
is there anybody out there?
I am also having this issue, headers are completely empty.
@Artem-Schander did you create any headers on the initial request? This should be fixed by using apollo-link
with the 2.0. Here is an upgrade guide if you are interested in the migration to links https://github.com/apollographql/apollo-client/blob/master/Upgrade.md#upgrading-from-custom-networkinteface-with-middleware--afterware
Additional comment here, the headers object in Chrome is actually of the type Headers. To get the values you actually need to do response.headers.get(key)
. This fixed the issue for me
Thanks to both of you, but update the apollo-client to v2 is in my case not an option. I'm using vue-apollo so the dependency is ^1.0
To receive headers, you need to expose them first on the server-side. You can read more on Access-Control-Expose-Headers
. If you're using cors
, you may use:
app.use(cors({
exposedHeaders: 'custom-header'
}));
I've found this information in this issue: https://github.com/apollographql/apollo-client/issues/1156
Most helpful comment
Additional comment here, the headers object in Chrome is actually of the type Headers. To get the values you actually need to do
response.headers.get(key)
. This fixed the issue for me