Browse Source

Fixed a bug in the dashboard api request

Thisnthat 4 years ago
parent
commit
18748d7543
1 changed files with 3 additions and 8 deletions
  1. 3 8
      dashboard.go

+ 3 - 8
dashboard.go

@@ -4,11 +4,10 @@ import (
 	"encoding/json"
 	"fmt"
 	"net/http"
-	"strings"
 )
 
 type DashboardResponse struct {
-	Dashboard Dashboard `json:"user"`
+	Dashboard Dashboard `json:"dashboard"`
 	Errors    []string  `json:"errors"`
 	ErrorType string    `json:"error_type"`
 }
@@ -43,14 +42,10 @@ func GetDashboard(config APIConfig) (Dashboard, error) {
 	}
 
 	if response.StatusCode == http.StatusOK || response.StatusCode == http.StatusForbidden {
-		var result *DashboardResponse
+		var result *Dashboard
 		json.NewDecoder(response.Body).Decode(&result)
 
-		if result.ErrorType != "" {
-			return Dashboard{}, fmt.Errorf("Failed to get discourse version. Error: %s", strings.Join(result.Errors, "; "))
-		}
-
-		return result.Dashboard, nil
+		return *result, nil
 	}
 
 	return Dashboard{}, fmt.Errorf("Unexpected response from discourse server at %s -- %s", url, response.Status)