request<T> method
Future<APIResponse<T>>
request<
T>( - String target,
- RequestType type, {
- Map<String, dynamic>? data,
- List<MultipartFile> files = const [],
- dynamic onFilesUpload(
- int bytes,
- int totalBytes
)?,
- bool log = false,
- dynamic onNoConnection()?,
- String errorsField = 'errors',
})
Implementation
Future<APIResponse<T>> request<T>(
String target,
RequestType type, {
Map<String, dynamic>? data,
List<http.MultipartFile> files = const [],
Function(int bytes, int totalBytes)? onFilesUpload,
bool log = false,
Map<String, String> headers = const {},
bool appendHeader = true,
// Function(String reqId)? onNoConnection,
Function()? onNoConnection,
String errorsField = 'errors',
}) =>
apiRequest.send(
target,
type,
data: data,
files: files,
onFilesUpload: onFilesUpload,
log: log,
headers: headers,
appendHeader: appendHeader,
onNoConnection: () async {
// if (cacheOnOffline) {
// var reqId = DateTime.now().millisecondsSinceEpoch;
// await storageDatabase.document('api/requests').set({
// '$reqId': {
// 'id': reqId,
// 'target': target,
// 'headers': headers,
// 'type': type.type,
// 'data': data,
// }
// });
// if (onNoConnection != null) onNoConnection('$reqId');
if (onNoConnection != null) onNoConnection();
// }
},
errorsField: errorsField,
);