fetch keeps giving me TypeError: Callback returned incorrect type; expected 'Promise'

I am in the middle of converting my service worker to a module app. I am able to publich but when getting to running it, when it hits: const resp = await fetch('https://csprng.xyz/v1/api') I get the following error in my tail logs: TypeError: Callback returned incorrect type; expected 'Promise' Would anybody have any idea why this is happening and how to resolve? I am running wrangler 2.8.1 Appreciate the tips
1 Reply
captain
captain2y ago
also of note, i have the fetch inside a function called: async function handleRequest(request, env) export default { fetch(request, env, context) { if(1 == 1) { handleRequest(request, env) } } } async function handleRequest(request, env) { const resCool = await fetch('https://csprng.xyz/v1/api') }
Want results from more Discord servers?
Add your server