Skip to content

Instantly share code, notes, and snippets.

@jadjoubran
Last active January 23, 2018 17:42
Show Gist options
  • Save jadjoubran/761fab3e464b9204d5bc881632a58372 to your computer and use it in GitHub Desktop.
Save jadjoubran/761fab3e464b9204d5bc881632a58372 to your computer and use it in GitHub Desktop.
importScripts('https://cdn.jsdelivr.net/npm/[email protected]/comlink.global.min.js');
class Fetch {
constructor()
getBaseUrl()
getDefaultHeaders()
getDefaultBody()
setBaseUrl(baseUrl)
setDefaultHeaders(defaultHeaders)
setDefaultBody(defaultBody)
async get(endpoint = '')
async post(endpoint = '', body = undefined, headers = {})
async put(endpoint = '', body = undefined, headers = {})
async delete(endpoint = '', body = undefined, headers = {})
async _send(method, endpoint = '', body = undefined, headers = {})
}
Comlink.expose({ Fetch }, self);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment