Created
October 2, 2023 21:45
-
-
Save flpms/7ffb5d320f2c63d91fbf8660cb8c64e1 to your computer and use it in GitHub Desktop.
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 characters
const host = 'https://api.github.com/'; | |
const request = { | |
const req = (path, method, opts, params) => { | |
return fetch(`${host}/v3/${path}?${params}`, { | |
headers, | |
method, | |
...opts | |
}); | |
}; | |
return { | |
get: (path, params, opt) => req(path, 'GET', opt, params), | |
del: path => req(path, 'DELETE'), | |
post: (path, data) => req(path, 'POST', { | |
body: JSON.stringify(data), | |
}), | |
put: (path, data) => req(path, 'PUT', { | |
body: JSON.stringify(data), | |
}), | |
}; | |
} | |
request.get('users'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment