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

2 messages · Page 1 of 1 (latest)

median grail
#

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

median grail
#

also of note, i have the fetch inside a function called: async function handleRequest(request, env)