check if userid response actually contains elements in slice

This commit is contained in:
lyx0 2024-02-14 21:57:58 +01:00
parent e09ec92a3b
commit 7cf1d4ade8

View file

@ -18,10 +18,11 @@ func IDByUsernameReply(username string) string {
return "xd" return "xd"
} }
defer resp.Body.Close()
responseList := make([]ivrIDByUsernameResponse, 0) responseList := make([]ivrIDByUsernameResponse, 0)
_ = json.NewDecoder(resp.Body).Decode(&responseList) err = json.NewDecoder(resp.Body).Decode(&responseList)
if len(responseList) == 0 {
return "xd"
}
reply := fmt.Sprintf("%s=%s", username, responseList[0].ID) reply := fmt.Sprintf("%s=%s", username, responseList[0].ID)
return reply return reply
@ -39,6 +40,9 @@ func IDByUsername(username string) string {
responseList := make([]ivrIDByUsernameResponse, 0) responseList := make([]ivrIDByUsernameResponse, 0)
_ = json.NewDecoder(resp.Body).Decode(&responseList) _ = json.NewDecoder(resp.Body).Decode(&responseList)
if len(responseList) == 0 {
return "xd"
}
return responseList[0].ID return responseList[0].ID
} }