yamiteru
04/06/2023, 1:46 PMdave
04/06/2023, 2:07 PMyamiteru
04/06/2023, 2:16 PMHardAtWork
04/06/2023, 2:20 PMHardAtWork
04/06/2023, 2:23 PManurag
04/06/2023, 5:15 PMwrangler dev
where does it get the KV data from?
Earlier I thought and noticed that it's storing the data on the actual edge that I could see on the CF dashboard but now there's a difference between the data in the KV on the dashboard and what I'm getting during local development.anurag
04/06/2023, 5:17 PMJames
04/06/2023, 5:17 PMwrangler dev
, if you use —local
, it’s entirely local, either in memory, or to disk if you also add —persist
. If you don’t, it’ll use real KV via whatever ID you use in the preview_id
in your wrangler.toml
anurag
04/06/2023, 5:19 PMpreview_id
KV and the normal id
?James
04/06/2023, 5:19 PManurag
04/06/2023, 5:20 PM--local
like when should someone use it?James
04/06/2023, 5:22 PManurag
04/06/2023, 5:26 PMHardAtWork
04/06/2023, 6:11 PMsameerali
04/06/2023, 8:40 PMHardAtWork
04/06/2023, 8:41 PMsameerali
04/06/2023, 9:13 PMSkye
04/06/2023, 9:14 PMSkye
04/06/2023, 9:14 PMsameerali
04/06/2023, 9:14 PMjschlesser
04/06/2023, 11:38 PM[mf:err] TypeError: Cannot read properties of undefined (reading 'middleware')
. Has anyone else run into this?jschlesser
04/07/2023, 12:16 AMnpm install wrangler@latest
fixed it. Recent bug fixautoxins
04/07/2023, 2:42 AMRequest
object in Cloudflare Worker not support the tee()
method??kian
04/07/2023, 3:01 AMRequest.body.tee()
kian
04/07/2023, 3:01 AMtee()
is implemented on ReadableStreams - and that's the body
propertyArnø
04/07/2023, 5:31 AMpresently
04/07/2023, 6:20 AMenv
is not available in the global 'scope' (?) when using modules syntax. Thus, this code which accesses env
from a function doesn't work.
js
async function listFiles() {
const fileList = await env.MY_BUCKET.list()
return new Response('Ok')
}
export default {
async fetch(request, env) {
return await listFiles()
},
}
Is there any way to get around that other than just passing env
to listFiles()
? I'm fine doing that but it seems tedious for the half dozen or so functions I'm making. Maybe there is some JS trick to make env
be accessible in its child functions.
Edit: I guess you can move the functions so they have access to the scope where env
is hiding.
js
export default {
async fetch(request, env) {
return await listFiles()
async function listFiles() {
const fileList = await env.MY_BUCKET.list()
return new Response('Ok')
}
},
}
Works for me, probably won't change it unless I'm told it's really bad practice for some reason.Tom Sherman
04/07/2023, 8:08 AMTom Sherman
04/07/2023, 8:09 AMCode6
04/07/2023, 12:56 PM