这是我的代码:
var url = 'http://myURL';
String tokens = "good token working on postman";
var response = await http.get(url, headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer $tokens',
});
print('Token : ${tokens}');
print(response.body);
问题是令牌和api网址在PostMan上运行良好,但看起来像flutter不能发送令牌。 它向我返回了网页内容。
答案 0 :(得分:1)
var response = await http
.get(Uri.parse('http://192.168.1.32:8000/api/users'), headers: {
'Authorization': 'Bearer ' + sharedPreferences.getString("access_token"),
});