load api root path from a constant
This commit is contained in:
parent
9b9956dcaa
commit
a504d0b53a
|
@ -1,8 +1,9 @@
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
const { API_ROOT } = require('../constants');
|
||||||
|
|
||||||
export default class ApartamentService {
|
export default class ApartamentService {
|
||||||
static async getAll(limit, offest) {
|
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: {
|
params: {
|
||||||
limit: limit,
|
limit: limit,
|
||||||
...(offest !== 0 ? {offset: offest} : {})
|
...(offest !== 0 ? {offset: offest} : {})
|
||||||
|
@ -12,7 +13,7 @@ export default class ApartamentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getById(id) {
|
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;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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 });
|
Loading…
Reference in New Issue