Skip to content

Instantly share code, notes, and snippets.

@flpms
Created October 2, 2023 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flpms/7ffb5d320f2c63d91fbf8660cb8c64e1 to your computer and use it in GitHub Desktop.
Save flpms/7ffb5d320f2c63d91fbf8660cb8c64e1 to your computer and use it in GitHub Desktop.
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