Skip to content

Commit

Permalink
fixed hard coded region in getReadings
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Mihai committed Dec 5, 2023
1 parent bbc0e8b commit 550f909
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func main() {
if isAuthSuccessful {
statusPanel.Text = "Authentication successfull"
go func() {
connectAndGetData(authToken, lcfg.RefreshInterval, glucosePanel, diffPanel, lastReadingPanel, statusPanel)
connectAndGetData(authToken, lcfg.Region, lcfg.RefreshInterval, glucosePanel, diffPanel, lastReadingPanel, statusPanel)
}()
} else {
statusPanel.Text = authToken
Expand Down Expand Up @@ -196,7 +196,7 @@ func setSettings(configurationFile string, a fyne.App) {

}

func connectAndGetData(authToken string, refreshInterval int, glucosePanel *canvas.Text, diffPanel *canvas.Text, lastReadingPanel *canvas.Text, statusPanel *canvas.Text) {
func connectAndGetData(authToken string, region string, refreshInterval int, glucosePanel *canvas.Text, diffPanel *canvas.Text, lastReadingPanel *canvas.Text, statusPanel *canvas.Text) {
oldGlucose := 0
oldTimeStamp := ""
lastDiff := 0
Expand All @@ -207,7 +207,7 @@ func connectAndGetData(authToken string, refreshInterval int, glucosePanel *canv
httpError := false
statusPanel.Color = config.DefaultColor
glucosePanel.Color = config.BlueColor
connResponseResult, err := utils.GetReadings(authToken)
connResponseResult, err := utils.GetReadings(authToken, region)
if err != nil {
statusPanel.Text = err.Error()
httpError = true
Expand Down
4 changes: 2 additions & 2 deletions utils/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (
"time"
)

func GetReadings(authToken string) (string, error) {
func GetReadings(authToken string, region string) (string, error) {
client := &http.Client{}
client.Timeout = 10 * time.Second

getUrl := "https://api-de.libreview.io/llu/connections"
getUrl := "https://api-" + region + ".libreview.io/llu/connections"

req, err := http.NewRequest("GET", getUrl, nil)
if err != nil {
Expand Down

0 comments on commit 550f909

Please sign in to comment.