File size: 731 Bytes
d54ea4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
export async function getApiKey() {
    try {
        const response = await fetch("https://cloud.mithrilsecurity.io/api/apiKeys/chat", {
            method: "GET",
            credentials: "include",
            headers: {
                "Content-Type": "application/json",
            },
        });

        if (response.ok) {
            // Parse the JSON response
            const data = await response.json();

            const apiKeyValue = data.value;

            return apiKeyValue;
        } else {
            // Handle errors
            console.error("API Key retrieval failed");
        }
    } catch (error) {
        // Handle network errors
        console.error("Network error", error);
    }
    return "";
}