minor const refactor

This commit is contained in:
msramalho
2024-10-29 18:05:52 +00:00
parent 1dc849e753
commit 3cd5651a50

View File

@@ -18,8 +18,6 @@ import {
} from "firebase/firestore"; } from "firebase/firestore";
import { firebaseAuth, firebaseFirestore } from "@/firebase.js"; import { firebaseAuth, firebaseFirestore } from "@/firebase.js";
const API_ENDPOINT = "https://auto-archiver-api.bellingcat.com";
export default createStore({ export default createStore({
state: { state: {
user: null, user: null,
@@ -28,6 +26,7 @@ export default createStore({
docs: [], docs: [],
loading: false, loading: false,
errorMessage: "", errorMessage: "",
API_ENDPOINT: "https://auto-archiver-api.bellingcat.com"
}, },
mutations: { mutations: {
setUser(state, user) { setUser(state, user) {
@@ -93,11 +92,11 @@ export default createStore({
} }
}, },
async checkActiveUser({ state, commit, dispatch }) { async checkActiveUser({ state, commit }) {
try { try {
commit("setErrorMessage", ""); commit("setErrorMessage", "");
const r = await fetch( const r = await fetch(
`${API_ENDPOINT}/user/active`, `${state.API_ENDPOINT}/user/active`,
{ {
method: "GET", method: "GET",
headers: { headers: {
@@ -112,7 +111,6 @@ export default createStore({
console.error("checkActiveUser (firebase.js): ", error); console.error("checkActiveUser (firebase.js): ", error);
commit("setErrorMessage", "Unable to check user status against the API"); commit("setErrorMessage", "Unable to check user status against the API");
} }
}, },
async getDocs({ state, commit }) { async getDocs({ state, commit }) {
@@ -152,7 +150,7 @@ export default createStore({
// send a post request to the API with the sheet ID in the body // send a post request to the API with the sheet ID in the body
// and a bearer auth token in the header // and a bearer auth token in the header
await fetch( await fetch(
`${API_ENDPOINT}/sheet`, `${state.API_ENDPOINT}/sheet`,
{ {
method: "POST", method: "POST",
headers: { headers: {