Add processing when pagination is nil
This commit is contained in:
parent
134128cb56
commit
22f47735b4
2 changed files with 26 additions and 15 deletions
17
mastodon.go
17
mastodon.go
|
@ -103,19 +103,18 @@ func (c *Client) doAPI(ctx context.Context, method string, uri string, params in
|
|||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
lh := resp.Header.Get("Link")
|
||||
if lh != "" {
|
||||
retPG, err := newPagination(lh)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*pg = *retPG
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return parseAPIError("bad request", resp)
|
||||
} else if res == nil {
|
||||
return nil
|
||||
} else if pg != nil {
|
||||
if lh := resp.Header.Get("Link"); lh != "" {
|
||||
pg2, err := newPagination(lh)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*pg = *pg2
|
||||
}
|
||||
}
|
||||
return json.NewDecoder(resp.Body).Decode(&res)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue