feat: add Flutter web build support
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
@@ -51,13 +50,13 @@ class ApiClient {
|
||||
bool authenticated = true,
|
||||
}) async {
|
||||
final request = http.Request(method, Uri.parse('$baseUrl$path'));
|
||||
request.headers[HttpHeaders.acceptHeader] = 'application/json';
|
||||
request.headers['accept'] = 'application/json';
|
||||
if (authenticated) {
|
||||
final token = _tokenProvider();
|
||||
if (token.isNotEmpty) request.headers[HttpHeaders.authorizationHeader] = token;
|
||||
if (token.isNotEmpty) request.headers['authorization'] = token;
|
||||
}
|
||||
if (body != null) {
|
||||
request.headers[HttpHeaders.contentTypeHeader] = 'application/json; charset=UTF-8';
|
||||
request.headers['content-type'] = 'application/json; charset=UTF-8';
|
||||
request.body = jsonEncode(body);
|
||||
}
|
||||
final streamed = await _client.send(request);
|
||||
|
||||
Reference in New Issue
Block a user