first commit
This commit is contained in:
commit
a2663f415e
144 changed files with 6324 additions and 0 deletions
28
lib/services/api_service.dart
Normal file
28
lib/services/api_service.dart
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:kettlebell_tracker/services/device_service.dart';
|
||||
|
||||
Future<void> sendTrainingToBackend({
|
||||
required int reps,
|
||||
required double rest,
|
||||
required int sets,
|
||||
}) async {
|
||||
final uuid = await DeviceIdService.getOrCreateUUID();
|
||||
final url = Uri.parse('http://192.169.178.43:8000/trainings/');
|
||||
final response = await http.post(
|
||||
url,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({
|
||||
'reps': reps,
|
||||
'rest': rest,
|
||||
'sets': sets,
|
||||
'uuid': uuid,
|
||||
}),
|
||||
);
|
||||
if (response.statusCode == 200) {
|
||||
print('Training erfolgreich an Backend gesendet.');
|
||||
} else {
|
||||
print('Fehler beim Senden: ${response.body}');
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue