Commit ec576b16 authored by Christopher Cottier's avatar Christopher Cottier

added backend api url to config, uses in api_util files

parent 38e8a2c7
class Config {
static baseApiUrl = "http://localhost:8080/api"; //env file
static orderHistoryApiUrlMethod = (userId) => `${this.baseApiUrl}/orders/byUser/${userId}`;
static baseApiUrl = "http://localhost:8080"; //env file
static orderHistoryApiUrlMethod = (userId) => `${this.baseApiUrl}/api/orders/byUser/${userId}`;
}
......
import axios from 'axios';
import Config from '../config';
export const fetchProducts = () => {
return axios.get("http://localhost:8080/api/products")
return axios.get(`${Config.baseApiUrl}/api/products`)
}
export const fetchPromotions = () => {
return axios.get("http://localhost:8080/api/promos")
return axios.get(`${Config.baseApiUrl}/api/promos`)
}
export const fetchProductsAndPromotions = () => {
return axios.get("http://localhost:8080/api/products-and-promos")
return axios.get(`${Config.baseApiUrl}/api/products-and-promos`)
}
\ No newline at end of file
import axios from 'axios';
import Config from '../config';
export const postUser = (user) => {
return axios.post("http://localhost:8080/api/users", user)
return axios.post(`${Config.baseApiUrl}/api/users`, user)
}
// export const postUser = (user) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment