Skip to content

Commit

Permalink
feat: add API#catch method
Browse files Browse the repository at this point in the history
  • Loading branch information
2fd committed Mar 17, 2020
1 parent 3454624 commit 0020ed3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/utils/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import RequestError from '../errors/RequestError'

export default class API {

static catch<T>(prom: Promise<T>) {
return prom.catch((err) => {
console.error(err)
return null
})
}

constructor(public readonly baseUrl: string, public readonly defaultOptions: RequestInit = {}) { }

url(path: string) {
Expand Down

0 comments on commit 0020ed3

Please sign in to comment.