Fix pagination
This commit is contained in:
parent
3b0a84e36c
commit
6f4a7e7b66
1 changed files with 5 additions and 1 deletions
|
@ -66,6 +66,10 @@ func scryfallSearch(query string, offset int) (results CardSearchResults, err er
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
err = json.NewDecoder(response.Body).Decode(&results)
|
err = json.NewDecoder(response.Body).Decode(&results)
|
||||||
results.Data = results.Data[cardoffset:]
|
maxoffset := cardoffset + 50
|
||||||
|
if maxoffset > len(results.Data) {
|
||||||
|
maxoffset = len(results.Data)
|
||||||
|
}
|
||||||
|
results.Data = results.Data[cardoffset:maxoffset]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue