Return JSON empty array when not found, and handle null arrays
This commit is contained in:
parent
d0adb9c4db
commit
af7f666eff
2 changed files with 3 additions and 2 deletions
|
@ -218,7 +218,7 @@ func (s *SQLStore) GetAllBlocks() ([]model.Block, error) {
|
|||
func blocksFromRows(rows *sql.Rows) ([]model.Block, error) {
|
||||
defer rows.Close()
|
||||
|
||||
var results []model.Block
|
||||
var results = []model.Block{}
|
||||
|
||||
for rows.Next() {
|
||||
var block model.Block
|
||||
|
|
|
@ -28,7 +28,8 @@ class OctoClient {
|
|||
private async getJson(response: Response, defaultValue: any = {}): Promise<any> {
|
||||
// The server may return null or malformed json
|
||||
try {
|
||||
return await response.json()
|
||||
const value = await response.json()
|
||||
return value || defaultValue
|
||||
} catch {
|
||||
return defaultValue
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue