Skip to content

Commit

Permalink
add get key handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Merkie committed Aug 23, 2024
1 parent a562bd5 commit 641dbfb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/ts/client/api/endpoints/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { PUBLIC_API_URL } from '$env/static/public';

const user = {
update: updateUser
update: updateUser,
getElevenLabsKey
};

export default user;
Expand All @@ -27,3 +28,19 @@ async function updateUser(body: {

return json;
}

async function getElevenLabsKey(token?: string) {
const response = await fetch(PUBLIC_API_URL + '/user/eleven-labs-key', {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token ? token : localStorage.getItem('token')}`
}
});

const json = (await response.json()) as {
key: string;
error: string;
};

return json;
}

0 comments on commit 641dbfb

Please sign in to comment.