Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
fix: just return empty object for empty responses (#9)
Browse files Browse the repository at this point in the history
* fix: just return empty object for empty responses

* fix: return undefined instead of empty object
  • Loading branch information
etamponi authored and zkochan committed Jan 7, 2018
1 parent ebb382f commit 17519f8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/connectStoreController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function (
})
}

function fetch(limit: (fn: () => PromiseLike<object>) => Promise<object>, url: string, body: object): Promise<object> { // tslint:disable-line
function fetch(limit: (fn: () => PromiseLike<object>) => Promise<object>, url: string, body: object): Promise<object | undefined> { // tslint:disable-line
return limit(async () => {
const response = await got(url, {
body: JSON.stringify(body),
Expand All @@ -48,6 +48,9 @@ function fetch(limit: (fn: () => PromiseLike<object>) => Promise<object>, url: s
return 100
},
})
if (!response.body) {
return undefined
}
return JSON.parse(response.body)
})
}
Expand Down

0 comments on commit 17519f8

Please sign in to comment.