Explorar o código

db url to config

Bernadette Elena Hammerle %!s(int64=3) %!d(string=hai) anos
pai
achega
57e19d24c6
Modificáronse 2 ficheiros con 8 adicións e 6 borrados
  1. 3 0
      src/config/variables.js
  2. 5 6
      src/helpers/dbHelpers.js

+ 3 - 0
src/config/variables.js

@@ -1,3 +1,6 @@
+export const dbUrl = "http://192.168.8.100:5000"
+//export const dbUrl = "http://localhost:5000"
+
 export const latitude = 48.336950;
 export const longitude = 14.320570;
 export const testPath = [[latitude, longitude],

+ 5 - 6
src/helpers/dbHelpers.js

@@ -1,8 +1,7 @@
-const serverUrl = "http://192.168.8.101:5000"
-//const serverUrl = "http://localhost:5000"
+import {dbUrl} from "./../config/variables";
 
 export const fetchPathKeys = () => {
-  return fetch(serverUrl + "/get-path")
+  return fetch(dbUrl + "/get-path")
     .then(res => {
       if(res.status >= 400) {
         throw new Error("Server responds with error!");
@@ -17,7 +16,7 @@ export const fetchPathKeys = () => {
 
 
 export const fetchPaths = () => {
-  return fetch(serverUrl + "/get-path")
+  return fetch(dbUrl + "/get-path")
     .then(res => {
       if(res.status >= 400) {
           throw new Error("Server responds with error!");
@@ -51,7 +50,7 @@ export function savePathToDb(){
     body: json
   }
 
-  return fetch(serverUrl + "/set-path", reqOptions)
+  return fetch(dbUrl + "/set-path", reqOptions)
     .then(res => {
       if(res.status >= 400) {
           throw new Error("Server responds with error!");
@@ -74,7 +73,7 @@ export function saveTimeToDb(data){
     body: json
   }
 
-  return fetch(serverUrl + "/set-time", reqOptions)
+  return fetch(dbUrl + "/set-time", reqOptions)
     .then(res => {
       if(res.status >= 400) {
         console.log(res.text)