From ffc248841c4670c1c40a5080c0b48c26cf294a2c Mon Sep 17 00:00:00 2001 From: hudaputrasantosa Date: Mon, 1 Apr 2024 04:34:21 +0700 Subject: [PATCH] add: var env and config --- .env.example | 3 ++- src/{helpers/VisitorCounter.js => config/firebase.js} | 0 src/pages/About/index.jsx | 4 ++-- src/pages/Blogs/hook/useFetch.js | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/{helpers/VisitorCounter.js => config/firebase.js} (100%) diff --git a/.env.example b/.env.example index 36454e8..051e874 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,5 @@ VITE_REACT_STORAGE_BUCKET= VITE_REACT_MESSAGE_SENDER_ID= VITE_REACT_ID= - VITE_REACT_MEASUREMENT_ID= \ No newline at end of file + VITE_REACT_MEASUREMENT_ID= + VITE_REACT_NOCODE_API_KEY= \ No newline at end of file diff --git a/src/helpers/VisitorCounter.js b/src/config/firebase.js similarity index 100% rename from src/helpers/VisitorCounter.js rename to src/config/firebase.js diff --git a/src/pages/About/index.jsx b/src/pages/About/index.jsx index c78ade7..99ea91b 100644 --- a/src/pages/About/index.jsx +++ b/src/pages/About/index.jsx @@ -10,7 +10,7 @@ import { } from "../../response/about"; import { useEffect, useState } from "react"; import { doc, getDoc, updateDoc } from "firebase/firestore"; -import db from "../../helpers/VisitorCounter"; +import db from "../../config/firebase"; const About = () => { const [visitor, setVisitor] = useState(); @@ -25,7 +25,7 @@ const About = () => { }); }) .catch((err) => { - console.log("no", err); + alert("error increment counter : ", err); }); }, []); diff --git a/src/pages/Blogs/hook/useFetch.js b/src/pages/Blogs/hook/useFetch.js index 1a27459..0284135 100644 --- a/src/pages/Blogs/hook/useFetch.js +++ b/src/pages/Blogs/hook/useFetch.js @@ -5,8 +5,7 @@ const useFetch = () => { const [data, setData] = useState(); const [error, setError] = useState(null); const [loading, setLoading] = useState(false); - const baseUrl = - "https://v1.nocodeapi.com/hudaputrasantosa/medium/GtTjqSVdQmiXkhVC"; + const baseUrl = import.meta.env.VITE_REACT_NOCODE_API_KEY; useEffect(() => { (async function () {