matth3o matth3o - 8 months ago 47
Dart Question

dart BrowserClient - how to read response headers?

I don't manage to read response headers using browser_client.dart :

import 'package:http/browser_client.dart';

var response =
await, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}, body: body);
print('Response headers: ${response.headers}');

Thanks for your help.


The server needs to allow the browser to expose the headers by listing the headers in the Access-control-expose-headers response header, otherwise you can see them in the browser devtools but when you try to read them in code, the browser will suppress them.

See also