Fix: user page doesn't work because of bad JSON parsing
This commit is contained in:
parent
ab13f590db
commit
b55c849f5e
2 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue