now sends username in Sent field. hopefully
This commit is contained in:
@@ -16,7 +16,7 @@ class HttpRequestService {
|
||||
/// Send data to the appropriate backend endpoint
|
||||
/// @param saveDataMap Optional map of data to send
|
||||
/// @param saveDataString Optional string of data to send
|
||||
/// @return Future<int> HTTP status code of the response
|
||||
/// @return Future[int] HTTP status code of the response
|
||||
static Future<int> httpRequest({Map<String, String>? saveDataMap, String? saveDataString}) async {
|
||||
// print(jsonEncode(place));
|
||||
|
||||
@@ -30,12 +30,22 @@ class HttpRequestService {
|
||||
Response response =
|
||||
Response(requestOptions: RequestOptions(path: ''), statusCode: 400);
|
||||
|
||||
|
||||
try {
|
||||
// Choose endpoint based on data type (camera trap vs excursion)
|
||||
if (saveDataMap != null && saveDataMap.containsKey("CID") || saveDataString != null && saveDataString.contains("CID")) {
|
||||
// write username in Sent field
|
||||
if (saveDataMap != null) {
|
||||
saveDataMap["Sent"] = prefs.getString("addresse1") ?? "";
|
||||
} else if (saveDataString != null){
|
||||
saveDataString.replaceAll("\"Sent\": \"\"", "\"Sent\": \"${prefs.getString("addresse1")}\"");
|
||||
}
|
||||
|
||||
response = await dio.post(prefs.getString('fotofallenApiAddress') ?? "",
|
||||
data: saveDataMap == null ? saveDataString : jsonEncode(saveDataMap));
|
||||
} else {
|
||||
// write username in Sent field
|
||||
|
||||
response = await dio.post(prefs.getString('exkursionenApiAddress') ?? "",
|
||||
data: saveDataMap == null ? saveDataString : jsonEncode(saveDataMap));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user