Changed from axios to fetch.
This commit is contained in:
parent
50958f3486
commit
eed47ba48c
@ -4,9 +4,13 @@ interface Env {
|
||||
|
||||
const handler: ExportedHandler<Env> = {
|
||||
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<Env> = {
|
||||
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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user