moved to env variables
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import Keycloak from "keycloak-js";
|
import Keycloak from "keycloak-js";
|
||||||
const keycloak = new Keycloak({
|
const keycloak = new Keycloak({
|
||||||
url: "https://keycloak.anxietyprime.de/",
|
url: process.env.REACT_APP_KC,
|
||||||
realm: "Jodel",
|
realm: "Jodel",
|
||||||
clientId: "jodel-frontend",
|
clientId: "jodel-frontend",
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,22 +2,20 @@ import axios from "axios"
|
|||||||
import {locationUtils} from "../utils/location";
|
import {locationUtils} from "../utils/location";
|
||||||
import keycloak from "../Authentification/Keycloak";
|
import keycloak from "../Authentification/Keycloak";
|
||||||
|
|
||||||
const path = "https://api.jodel.anxietyprime.de";
|
|
||||||
|
|
||||||
export const postApi = {
|
export const postApi = {
|
||||||
async getPostsByCoords (lat, lon) {
|
async getPostsByCoords (lat, lon) {
|
||||||
if (!keycloak.authenticated) return [];
|
if (!keycloak.authenticated) return [];
|
||||||
return (await axios.get(`${path}/posts/${lat}/${lon}`)).data;
|
return (await axios.get(`${process.env.REACT_APP_API}/posts/${lat}/${lon}`)).data;
|
||||||
},
|
},
|
||||||
async getPostByID (id) {
|
async getPostByID (id) {
|
||||||
if (!keycloak.authenticated) return [];
|
if (!keycloak.authenticated) return [];
|
||||||
return (await axios.get(`${path}/post/${id}`)).data;
|
return (await axios.get(`${process.env.REACT_APP_API}/post/${id}`)).data;
|
||||||
},
|
},
|
||||||
async createNewPost(title, content, parent = null) {
|
async createNewPost(title, content, parent = null) {
|
||||||
const location = await locationUtils.getCurrentLocation();
|
const location = await locationUtils.getCurrentLocation();
|
||||||
if(location.lon && location.lat) {
|
if(location.lon && location.lat) {
|
||||||
if(parent !== null) {
|
if(parent !== null) {
|
||||||
await axios.post(`${path}/posts`, {
|
await axios.post(`${process.env.REACT_APP_API}/posts`, {
|
||||||
"authorID": 1,
|
"authorID": 1,
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": content,
|
"content": content,
|
||||||
@@ -29,7 +27,7 @@ export const postApi = {
|
|||||||
"parent": parent
|
"parent": parent
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await axios.post(`${path}/posts`, {
|
await axios.post(`${process.env.REACT_APP_API}/posts`, {
|
||||||
"authorID": 1,
|
"authorID": 1,
|
||||||
"title": title,
|
"title": title,
|
||||||
"content": content,
|
"content": content,
|
||||||
@@ -45,6 +43,6 @@ export const postApi = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async reactToPost(id, reaction) {
|
async reactToPost(id, reaction) {
|
||||||
await axios.patch(`${path}/post/${id}`, {reaction: reaction});
|
await axios.patch(`${process.env.REACT_APP_API}/post/${id}`, {reaction: reaction});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user