ammaratef45 / ammaratef45/hydroponics-garden

parse the response to get the value

Đang mở
#39 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
todo
Ngôn ngữ chính
Dart
Star
2
Fork
1
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

https://api.github.com/ammaratef45/hydroponics-garden/blob/0e5db9a0f6345f477e14392d9e1f93c20cb04f1f/lib/apis/api.dart#L38

```dart

throw Exception('Failed to set brightness');
}
}

Future isPumpOn() async {
final response = await http.get(Uri.parse('$baseUrl/pump/stats'));
if (response.statusCode == 200) {
// TODO parse the response to get the value
return true;
} else {
throw Exception('Failed to load pump status');
}
}

Future pumpOnOff(bool on) async {
final response = await http.post(
Uri.parse('$baseUrl/pump/${on ? 'on' : 'off'}'),
headers: {
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
log.d('Successfully adjusted pump');
} else {
throw Exception('Failed to adjust pump');
}
}
}

```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.