Created
January 23, 2018 16:32
-
-
Save jadjoubran/780b5a462b096f723015c670ca677420 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
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