Uncaught (in promise) error

Hey, I'm tryna make a file uploading system. My full code is https://pastebin.com/dUCApxp4, but this should be the important part:
export default {
  async fetch(request, env) {
    const url = new URL(request.url);
    const key = url.pathname.slice(1);

    const { pathname } = new URL(request.url);
    if(pathname == "/") {
      return new Response("CDN is working! :D")
    }

    switch (request.method) {
      case 'PUT':
        if(request.headers["Authorization"] != "nop!") return "no, go away"
        await env.data.put(key, request.body, {
          customMetadata: Record({"uploader":request.headers["Author"]})
        });
        return "helo mate"
...

However, when I sent a
PUT
request with the valid headers and data, it returns 500, and the logs show
Uncaught (in promise) TypeError: Incorrect type for Promise: the Promise did not resolve to 'Response'.
. I've been trying to fix this for a very long time, so any help would be appreciated!
Was this page helpful?