From eed47ba48c085b750f194e054f1553df1382cd31 Mon Sep 17 00:00:00 2001 From: Michael Mainguy Date: Thu, 10 Aug 2023 15:37:39 -0500 Subject: [PATCH] Changed from axios to fetch. --- functions/api/voice/token.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/functions/api/voice/token.ts b/functions/api/voice/token.ts index 1df1733..49651fe 100644 --- a/functions/api/voice/token.ts +++ b/functions/api/voice/token.ts @@ -4,9 +4,13 @@ interface Env { const handler: ExportedHandler = { async fetch(request, env) { + console.log(env); + console.log(request); + async function gatherResponse(response) { const {headers} = response; const contentType = headers.get("content-type") || ""; + console.log(contentType); if (contentType.includes("application/json")) { return JSON.stringify(await response.json()); } @@ -19,8 +23,10 @@ const handler: ExportedHandler = { headers: {authorization: env.VOICE_TOKEN} }; const response = await fetch('https://api.assemblyai.com/v2/realtime/token', init); + console.log('here'); const results = await gatherResponse(response); - return new Response(results); + console.log(results); + return new Response(results, {headers: "content-type: application/json", status: 200}); } } export default handler;