feat: generate code API

This commit is contained in:
2025-05-25 14:12:27 +02:00
parent 428dc50aa1
commit 34c1ce7652

25
web/src/api/code.ts Normal file
View File

@ -0,0 +1,25 @@
import { handleApiError } from ".";
export interface CodeResponse {
code: string;
}
export const codeApi = async (accessToken: string, nonce: string) => {
const response = await fetch("/api/v1/oauth/code", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${accessToken}`,
},
body: JSON.stringify({
nonce,
}),
});
if (response.status !== 200 && response.status !== 201)
throw await handleApiError(response);
const data: CodeResponse = await response.json();
return data;
};