fix(api): ensure getFavoriteGifs doesn't error when response is empty
This commit is contained in:
parent
41654bf49d
commit
6cf3574dcd
|
@ -149,11 +149,14 @@ func (api *API) GetFavoriteGifs() (favoriteGifs []Gif, err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
favoriteGifs = make([]Gif, 0)
|
||||||
savedFavGifs := []Gif{}
|
savedFavGifs := []Gif{}
|
||||||
err = json.Unmarshal(gifs, &savedFavGifs)
|
if len(gifs) > 0 {
|
||||||
if err != nil {
|
err = json.Unmarshal(gifs, &savedFavGifs)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
favoriteGifs = savedFavGifs
|
||||||
}
|
}
|
||||||
favoriteGifs = savedFavGifs
|
|
||||||
return favoriteGifs, nil
|
return favoriteGifs, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue