diff --git a/handler/pixiv.go b/handler/pixiv.go index 227f1e4..cde7ae7 100644 --- a/handler/pixiv.go +++ b/handler/pixiv.go @@ -383,7 +383,7 @@ func (p *PixivClient) GetUserInformation(id string, page int) (*models.User, err var body struct { *models.User - Background map[string]string `json:"background"` + Background map[string]interface{} `json:"background"` } // Basic user information @@ -400,7 +400,7 @@ func (p *PixivClient) GetUserInformation(id string, page int) (*models.User, err // Background image if body.Background != nil { - user.BackgroundImage = body.Background["url"] + user.BackgroundImage = body.Background["url"].(string) } // Artworks count diff --git a/views/routes.go b/views/routes.go index 9f82bbb..5cf87a7 100644 --- a/views/routes.go +++ b/views/routes.go @@ -81,7 +81,14 @@ func user_page(c *gin.Context) { } pageInt, _ := strconv.Atoi(page) - user, _ := PC.GetUserInformation(id, pageInt) + user, err := PC.GetUserInformation(id, pageInt) + if err != nil { + c.HTML(http.StatusInternalServerError, "error.html", gin.H{ + "Title": "An error occured", + "Error": err, + }) + return + } worksCount, _ := PC.GetUserArtworksCount(id) pageLimit := math.Ceil(float64(worksCount)/30.0) + 1.0