From c777152c04b8cc1f8a1b07e05bdd61d38180fb38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sun, 22 Dec 2024 21:55:25 +0100 Subject: [PATCH] Only separat data and status when needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- advanced/Scripts/api.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/api.sh b/advanced/Scripts/api.sh index 43c91d69..785b8309 100755 --- a/advanced/Scripts/api.sh +++ b/advanced/Scripts/api.sh @@ -165,15 +165,16 @@ GetFTLData() { # get the data from querying the API as well as the http status code response=$(curl -skS -w "%{http_code}" -X GET "${API_URL}$1" -H "Accept: application/json" -H "sid: ${SID}" ) - # status are the last 3 characters - status="${response#"${response%???}"}" - # data is everything from response without the last 3 characters - data="${response%???}" - if [ "${2}" = "raw" ]; then # return the raw response echo "${response}" else + + # status are the last 3 characters # status are the last 3 characters + status="${response#"${response%???}"}" + # data is everything from response without the last 3 characters + data="${response%???}" + # return only the data if [ "${status}" = 200 ]; then # response OK