Skip to content

Commit

Permalink
fix: null deals (#235)
Browse files Browse the repository at this point in the history
The value "null" was found in the DB and parses to `null`. This PR checks the parsed value is not `null` also.
  • Loading branch information
Alan Shaw authored Jul 6, 2021
1 parent 98d83ea commit aad1259
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/api/src/models/deals.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ import { stores } from '../constants.js'
*/
export const get = async (cid) => {
const data = await stores.deals.get(cid)
return data == null ? [] : JSON.parse(data)
if (data == null) return []
const deals = JSON.parse(data)
return Array.isArray(deals) ? deals : []
}

0 comments on commit aad1259

Please sign in to comment.