Reputation: 6918
The way I tried to post a data to the server, and then the server return the detail message which is encapsulated in response header for me, how to get this message out of response header?
var response = await http.post(...);
var detail_message = response['header'];
Upvotes: 0
Views: 1656
Reputation: 12575
You must decode your response data if header response
var decodedData = jsonDecode(response);
var detail_message = decodedData['header'];
Otherwise:
var detail_message = response.headers;
Upvotes: 1
Reputation: 1610
https://pub.dev/documentation/http/latest/http/Response-class.html
var response = await http.post(...);
print('Response status: ${response.statusCode}');
print('Response body: ${response.headers}');
print('Response body: ${response.body}');
Upvotes: 0