Return JSON empty array when not found, and handle null arrays

This commit is contained in:
Chen-I Lim 2021-03-08 16:08:17 -08:00
parent d0adb9c4db
commit af7f666eff
2 changed files with 3 additions and 2 deletions

View file

@ -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

View file

@ -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
}