diff --git a/pairent_frontend_react/src/API/ApartamentService.js b/pairent_frontend_react/src/API/ApartamentService.js index acfbb63..f4f0fe1 100644 --- a/pairent_frontend_react/src/API/ApartamentService.js +++ b/pairent_frontend_react/src/API/ApartamentService.js @@ -1,8 +1,9 @@ import axios from 'axios'; +const { API_ROOT } = require('../constants'); export default class ApartamentService { static async getAll(limit, offest) { - const response = await axios.get('http://127.0.0.1:8000/api/apartaments/', { + const response = await axios.get(API_ROOT + '/api/apartaments/', { params: { limit: limit, ...(offest !== 0 ? {offset: offest} : {}) @@ -12,7 +13,7 @@ export default class ApartamentService { } static async getById(id) { - const response = await axios.get('http://127.0.0.1:8000/api/apartament/' + id) + const response = await axios.get(API_ROOT + '/api/apartament/' + id) return response; } } \ No newline at end of file diff --git a/pairent_frontend_react/src/constants.js b/pairent_frontend_react/src/constants.js new file mode 100644 index 0000000..1555b96 --- /dev/null +++ b/pairent_frontend_react/src/constants.js @@ -0,0 +1,12 @@ +/** + * Api root path + * @type {string} + */ +const API_ROOT = + window.location.protocol + + + import.meta.env.DEV ? + '//127.0.0.1:8000' : + '//pairent.vvsu.ru'; + +module.exports = Object.freeze({ API_ROOT }); \ No newline at end of file