load api root path from a constant

This commit is contained in:
b1ek 2023-05-05 17:55:40 +10:00
parent 9b9956dcaa
commit a504d0b53a
Signed by: blek
GPG Key ID: 14546221E3595D0C
2 changed files with 15 additions and 2 deletions

View File

@ -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;
}
}

View File

@ -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 });