Last active
August 31, 2019 19:42
-
-
Save sultaniman/88c24066e7bfd283f64145eef7b19e7f to your computer and use it in GitHub Desktop.
This file contains 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 characters
/* | |
* Wraps axios and provides | |
* more convenient post method | |
* calls with payload data | |
*/ | |
export function post(uri, data) { | |
return axios.post(uri, data, { | |
headers: getHeaders(), | |
withCredentials: true | |
}) | |
} | |
/* | |
* Wraps axios and provides | |
* more convenient put method | |
* calls with data | |
*/ | |
export function put(uri, data) { | |
return axios.put(uri, data, { | |
headers: getHeaders(), | |
withCredentials: true | |
}) | |
} | |
/* | |
* Wraps axios and provides | |
* more convenient delete method | |
*/ | |
export function remove(uri) { | |
return axios.delete(uri, { | |
headers: getHeaders(), | |
withCredentials: true | |
}) | |
} | |
/* | |
* Wraps axios and provides | |
* more convenient get method | |
* calls with data. | |
*/ | |
export function get(uri, data = {}) { | |
if (Object.keys(data).length > 0) { | |
uri = `${uri}?${qs(data)}` | |
} | |
return axios.get(uri, { | |
headers: getHeaders(), | |
withCredentials: true | |
}) | |
} | |
export function upload(uri, data) { | |
return fetch(uri, { | |
headers: getHeaders(true), | |
cors: true, | |
method: 'POST', | |
body: data | |
}) | |
} |
douglasg14b
commented
Aug 31, 2019
via email
Thanks for the response!
Unfortunately code is copyright by default unless explicitly stated
otherwise. Assumptions can't be made as you (or anyone with unlicenced,
copyrighted code) could assert their copyright at anytime in the future.
Pmuch this means unlicenced code cannot be touched. These examples would
quickly flag in in a copyright audit.
I'd recommend adding a licence like MIT, which as as simple as copy/pasting
the licence doc into a licence.md file in the repository root. I believe
GitHub also provides a way to select licenses.
…On Sat, Aug 31, 2019, 1:29 AM Sultan Iman ***@***.***> wrote:
I am not sure if it is possible in gists but this gist is a part of my
blogpost
***@***.***/handling-api-calls-in-vue-cf39747656ba so
assume it is free to copy/reproduce etc.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/88c24066e7bfd283f64145eef7b19e7f?email_source=notifications&email_token=AAKV4PCGEAIC6K4ZPUBZVKTQHITWVA5CNFSM4IR3OQHKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFX5MA#gistcomment-3013312>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKV4PER6C5LGDSY6M6M2ILQHITWVANCNFSM4IR3OQHA>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment