Create ApiHelpers to isolate api/url building

This commit is contained in:
Tanish Manku committed 2024-12-19 18:43:50 -08:00
1 parent 8e1cff3e19
commit ac290da7ef
1 file changed
+18
+18
View File
@@ -0,0 +1,18 @@
import environmentVariables from "./EnvironmentVariables";
export async function get_media_url(mediaId: string) {
//This is for prod when we have the proper info on the url.
const api_base_url = environmentVariables.values.BASE_API;
const url = `${api_base_url}/v1/media_files/file/${mediaId}`;
const response = await fetch(url);
const json = await JSON.parse(await response.text());
const bucketPath = json["media_file"]["public_bucket_path"];
//const media_api_base_url = environmentVariables.values.GOOGLE_API;
const media_api_base_url = "https://cdn-2.fakeyou.com";
//const media_base_url = `${media_api_base_url}/vocodes-public`;
//const media_url = `${media_base_url}${bucketPath}`;
const media_url = `${media_api_base_url}${bucketPath}`;
return media_url;
}