Skip to content

Instantly share code, notes, and snippets.

@schabluk
schabluk / Promises.js
Last active May 20, 2021 10:56
Array / Object Tools
// Delaying response
let delay = time => result => new Promise(resolve => setTimeout(() => resolve(result), time))
const result = await fetch(endpoint).then(delay(1000)).then(data => data.json())
// Mocking Fetch
window.fetch = function () {
const body = { hello: "world" }
const blob = new Blob([JSON.stringify(body, null, 2)], { type : 'application/json' })