Skip to content

Commit

Permalink
Fix case when no KV store exists
Browse files Browse the repository at this point in the history
  • Loading branch information
gustafnk committed Aug 31, 2023
1 parent 1dcea82 commit 64f93e2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions upload-polyfills.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ async function getOrCreatePolyfillKVStore() {
}
}())

env.STORE_ID = stores.data.find(({ name }) => name === 'polyfill-library')?.id
if (!env.STORE_ID) {
const storeId = stores.data.find(({ name }) => name === 'polyfill-library')?.id
if (!storeId) {
env.STORE_ID = await fetch("https://api.fastly.com/resources/stores/kv", {
method: 'POST',
headers: {
Expand All @@ -73,7 +73,9 @@ async function getOrCreatePolyfillKVStore() {
},
body: '{"name":"polyfill-library"}'
})
env.STORE_ID = (await env.STORE_ID.json()).id
env.STORE_ID = (await storeId.json()).id
} else {
env.STORE_ID = storeId;
}
}

Expand Down

0 comments on commit 64f93e2

Please sign in to comment.