ELEC60013-ES-CW1/lib/service/steps_service.dart

17 lines
548 B
Dart
Raw Normal View History

2022-02-14 20:19:04 +00:00
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:leg_barkr_app/utils/endpoints.dart' as Endpoints;
class StepsService {
Future<int> getStepsToday(deviceId) async {
final response = await http.get(
Uri.parse(Endpoints.getStepsToday),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
'deviceid': deviceId,
},
);
print(jsonDecode(response.body)['cumulative_steps_today']);
return jsonDecode(response.body)['cumulative_steps_today'];
}
}