Created
November 9, 2019 12:14
-
-
Save takahirohonda/11e30440e842b1647a904287213c2338 to your computer and use it in GitHub Desktop.
replacing-local-storage-with-indexeddb-4-insert-then-read.ts
This file contains hidden or 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
export const initialiseDbAndFetchData = async () => { | |
const initialDataArray = [ | |
initialList, | |
initialCategories | |
] | |
const keyArray = ['list', 'category'] | |
if (checkIndexDbBrowserSupport) { | |
try { | |
const dbInitialized = await initialiseDb(initialDataArray, keyArray) | |
if (dbInitialized) { | |
return Promise.all([ | |
getDataFromIndexedDb('list'), | |
getDataFromIndexedDb('category') | |
]).then((values: any) => { | |
return values | |
}) | |
} | |
} catch (e) { | |
console.log('error in resolving getDataFromIndexDb promise') | |
} | |
} | |
} | |
// Now we can finally get data... | |
try { | |
const data = await initialiseDbAndFetchData() | |
console.log('checking data, ', data) | |
return data | |
} catch (e) { | |
console.log(e) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment