Last active
April 26, 2020 08:18
-
-
Save oluosiname/04f824927fdfeb1e5e73b1b1b8bd02e3 to your computer and use it in GitHub Desktop.
Revisions
-
oluosiname revised this gist
Apr 26, 2020 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ class Http { async get({ url, ...rest }) { const init = {...this.getInit, ...rest}; try { const response = await fetch.get(url, init); return response.json(); @@ -15,7 +16,7 @@ class Http { } } async post({ url, body, ...rest }) { const init = {...this.postInit, ...rest}; try { -
oluosiname created this gist
Apr 25, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ class Http { constructor() { this.postInit = { method: 'POST' } this.getInit = { method: 'GET' } } async get({ url, ...rest }) { const init = {...this.getInit, ...rest}; try { const response = await fetch.get(url, init); return response.json(); } catch (e) { throw e; } } async post({ url, ...rest }) { const init = {...this.postInit, ...rest}; try { const response = await fetch(url, init); return response.json(); } catch (e) { throw e; } } }