Skip to content

Instantly share code, notes, and snippets.

@jadjoubran
Created January 23, 2018 16:32
Show Gist options
  • Save jadjoubran/780b5a462b096f723015c670ca677420 to your computer and use it in GitHub Desktop.
Save jadjoubran/780b5a462b096f723015c670ca677420 to your computer and use it in GitHub Desktop.
import { Comlink } from './node_modules/comlinkjs/comlink.es6.js';
const worker = new Worker('./node_modules/comlink-fetch/src/fetch.worker.js');
const proxy = Comlink.proxy(worker);
async function getSecondaryInfo() {
const API = await new proxy.Fetch;
API.setBaseUrl("https://jsonplaceholder.typicode.com/");
API.setDefaultHeaders({ 'Content-Type': 'application/json' });
API.setDefaultBody({ lang: 'en' });
let page1 = API.get('posts/1');
let page2 = API.get('posts/2');
console.log(await page1);
console.log(await page2);
}
getSecondaryInfo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment