mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-05-23 12:07:10 +00:00
feat: something with something
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { authFetch } from ".";
|
||||
import { apiFetch } from ".";
|
||||
|
||||
interface AuthResponse {
|
||||
token: string;
|
||||
@@ -9,14 +9,14 @@ export const signup = async (body: {
|
||||
username: string;
|
||||
password: string;
|
||||
}) => {
|
||||
return await authFetch<AuthResponse>("/sign-up", {
|
||||
return await apiFetch<AuthResponse>("/sign-up", {
|
||||
method: "POST",
|
||||
body,
|
||||
});
|
||||
};
|
||||
|
||||
export const login = async (body: { email: string; password: string }) => {
|
||||
return await authFetch<AuthResponse>("/sign-in", {
|
||||
return await apiFetch<AuthResponse>("/sign-in", {
|
||||
method: "POST",
|
||||
body,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { userFetch } from ".";
|
||||
import { Competition } from "../types/competition";
|
||||
|
||||
export const getCompetitions = async (participating?: boolean) => {
|
||||
return await userFetch<Competition[]>("/competitions", {
|
||||
params: {
|
||||
is_participating: participating,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const getCompetition = async (id: string) => {
|
||||
return await userFetch<Competition>(`/competition/${id}`);
|
||||
};
|
||||
@@ -14,17 +14,16 @@ export class ApiError extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
export const authFetch = ofetch.create({
|
||||
export const apiFetch = ofetch.create({
|
||||
baseURL: BASE_URL,
|
||||
async onResponseError({ response }) {
|
||||
throw new ApiError(response);
|
||||
},
|
||||
});
|
||||
|
||||
export const apiFetch = ofetch.create({
|
||||
export const userFetch = ofetch.create({
|
||||
baseURL: BASE_URL,
|
||||
async onRequest({ options }) {
|
||||
console.log(import.meta.env.VITE_API_ENDPOINT);
|
||||
options.headers.set("Authorization", "Bearer " + getToken());
|
||||
},
|
||||
async onResponseError({ response }) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { apiFetch } from ".";
|
||||
import { Reviewer } from "../types/review";
|
||||
|
||||
export const getReviewer = async (token: string) => {
|
||||
return await apiFetch<Reviewer>(`/review/${token}`);
|
||||
};
|
||||
|
||||
export const getReviewerSubmissions = async (token: string) => {
|
||||
return await apiFetch(`/review/${token}/submissions`);
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { apiFetch } from ".";
|
||||
import { userFetch } from ".";
|
||||
import { User } from "../types/user";
|
||||
|
||||
export const getCurrentUser = async () => {
|
||||
return await apiFetch<User>("/me");
|
||||
return await userFetch<User>("/me");
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user