matth3o matth3o - 1 month ago 7x
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