From 57dc31e60da2c519ace36ea89d1d5cc2c84f5710 Mon Sep 17 00:00:00 2001 From: 1ilit <1ilit@proton.me> Date: Mon, 21 Apr 2025 22:02:53 +0400 Subject: [PATCH] clean up .env.sample and gist apis --- .env.sample | 3 +-- src/api/gists.js | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.env.sample b/.env.sample index 153c5ae..c87806f 100644 --- a/.env.sample +++ b/.env.sample @@ -1,2 +1 @@ -VITE_BACKEND_URL=http://backend.com -VITE_GITHUB_ACCESS_TOKEN=my_access_token \ No newline at end of file +VITE_BACKEND_URL=http://backend.com \ No newline at end of file diff --git a/src/api/gists.js b/src/api/gists.js index f2920f4..d2b7b39 100644 --- a/src/api/gists.js +++ b/src/api/gists.js @@ -3,8 +3,10 @@ import axios from "axios"; const filename = "share.json"; const description = "drawDB diagram"; +const baseUrl = import.meta.env.VITE_BACKEND_URL; + export async function create(content) { - const res = await axios.post(`${import.meta.env.VITE_BACKEND_URL}/gists`, { + const res = await axios.post(`${baseUrl}/gists`, { public: false, filename, description, @@ -15,20 +17,18 @@ export async function create(content) { } export async function patch(gistId, content) { - await axios.patch(`${import.meta.env.VITE_BACKEND_URL}/gists/${gistId}`, { + await axios.patch(`${baseUrl}/gists/${gistId}`, { filename, content, }); } export async function del(gistId) { - await axios.delete(`${import.meta.env.VITE_BACKEND_URL}/gists/${gistId}`); + await axios.delete(`${baseUrl}/gists/${gistId}`); } export async function get(gistId) { - const res = await axios.get( - `${import.meta.env.VITE_BACKEND_URL}/gists/${gistId}`, - ); + const res = await axios.get(`${baseUrl}/gists/${gistId}`); return res.data; }