Commit f2c5b702 authored by Aral Balkan's avatar Aral Balkan

Make fetch polyfill return Promise and expect it when used

(Thanks to https://github.com/paberr for catching that.)
parent 76cae0ca
......@@ -8,7 +8,7 @@ async function _fetch (file) {
const fs = require('fs')
const util = require('util')
const fileContents = await util.promisify(fs.readFile)(file, 'binary')
return { blob: function () { return fileContents } }
return { blob: function () { return Promise.resolve(fileContents) } }
}
const fetchUniversal = isRunningInBrowser ? fetch : _fetch
......@@ -27,12 +27,11 @@ db.createObjectStore('images')
const store = db.getObjectStore('images')
const imageResponse = await fetchUniversal('aral.jpg')
const imageBlob = imageResponse.blob()
const imageBlob = await imageResponse.blob()
const tx = store.transaction()
await tx.put('aral', imageBlob)
await tx.commit()
// const tx = store.transaction()
await store.put('aral', imageBlob)
// await tx.commit()
// Get the blob back from the database
const imageBlobFromDatabase = await store.get('aral')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment