Backend-Adresse aus .env file beziehen

This commit is contained in:
Torsten Schulz
2024-06-15 23:29:41 +02:00
parent 61653ff407
commit 4e371f88b1
23 changed files with 568 additions and 83 deletions

View File

@@ -143,7 +143,7 @@ export default {
},
async saveMenuData() {
try {
await fetch('http://localhost:3000/api/menu-data', {
await fetch('/menu-data', {
method: 'POST',
headers: {
'Content-Type': 'application/json'

View File

@@ -45,7 +45,7 @@ export default {
methods: {
async fetchContactPersons() {
try {
const response = await axios.get('http://localhost:3000/api/contact-persons');
const response = await axios.get('/contact-persons');
this.contactPersons = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Kontaktpersonen:', error);
@@ -53,7 +53,7 @@ export default {
},
async fetchPositions() {
try {
const response = await axios.get('http://localhost:3000/api/positions');
const response = await axios.get('/positions');
this.positions = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Positionen:', error);

View File

@@ -99,7 +99,7 @@ export default {
const fetchPages = async () => {
try {
const response = await axios.get('http://localhost:3000/api/menu-data');
const response = await axios.get('/menu-data');
pages.value = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Seiten:', error);

View File

@@ -65,11 +65,11 @@ export default {
async fetchData() {
try {
const [eventResponse, institutionResponse, eventPlaceResponse, contactPersonResponse, eventTypeResponse] = await Promise.all([
axios.get('http://localhost:3000/api/events'),
axios.get('http://localhost:3000/api/institutions'),
axios.get('http://localhost:3000/api/event-places'),
axios.get('http://localhost:3000/api/contact-persons'),
axios.get('http://localhost:3000/api/event-types')
axios.get('/events'),
axios.get('/institutions'),
axios.get('/event-places'),
axios.get('/contact-persons'),
axios.get('/event-types')
]);
this.events = eventResponse.data;
@@ -91,7 +91,7 @@ export default {
},
async deleteEvent(id) {
try {
await axios.delete(`http://localhost:3000/api/events/${id}`);
await axios.delete(`/events/${id}`);
this.fetchData();
} catch (error) {
console.error('Fehler beim Löschen der Veranstaltung:', error);

View File

@@ -55,25 +55,25 @@ export default {
},
methods: {
async fetchEventPlaces() {
const response = await axios.get('http://localhost:3000/api/event-places');
const response = await axios.get('/event-places');
this.eventPlaces = response.data;
},
async addEventPlace() {
if (this.editMode) {
await axios.put(`http://localhost:3000/api/event-places/${this.editId}`, this.newEventPlace);
await axios.put(`/event-places/${this.editId}`, this.newEventPlace);
} else {
const response = await axios.post('http://localhost:3000/api/event-places', this.newEventPlace);
const response = await axios.post('/event-places', this.newEventPlace);
this.eventPlaces.push(response.data);
}
this.resetForm();
await this.fetchEventPlaces();
},
async updateEventPlace(eventPlace) {
await axios.put(`http://localhost:3000/api/event-places/${eventPlace.id}`, eventPlace);
await axios.put(`/event-places/${eventPlace.id}`, eventPlace);
this.fetchEventPlaces(); // Refresh the list
},
async deleteEventPlace(id) {
await axios.delete(`http://localhost:3000/api/event-places/${id}`);
await axios.delete(`/event-places/${id}`);
this.fetchEventPlaces(); // Refresh the list
},
editEventPlace(eventPlace) {

View File

@@ -35,7 +35,7 @@
methods: {
async fetchEventTypes() {
try {
const response = await axios.get('http://localhost:3000/api/event-types');
const response = await axios.get('/event-types');
this.eventTypes = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Event-Typen:', error);
@@ -44,9 +44,9 @@
async saveEventType() {
try {
if (this.editMode) {
await axios.put(`http://localhost:3000/api/event-types/${this.editId}`, this.eventTypeData);
await axios.put(`/event-types/${this.editId}`, this.eventTypeData);
} else {
const response = await axios.post('http://localhost:3000/api/event-types', this.eventTypeData);
const response = await axios.post('/event-types', this.eventTypeData);
this.eventTypes.push(response.data);
}
this.resetForm();
@@ -62,7 +62,7 @@
},
async deleteEventType(id) {
try {
await axios.delete(`http://localhost:3000/api/event-types/${id}`);
await axios.delete(`/event-types/${id}`);
await this.fetchEventTypes();
} catch (error) {
console.error('Fehler beim Löschen des Event-Typs:', error);

View File

@@ -77,7 +77,7 @@ export default {
methods: {
async fetchInstitutions() {
try {
const response = await axios.get('http://localhost:3000/api/institutions');
const response = await axios.get('/institutions');
this.institutions = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Institutionen:', error);
@@ -85,7 +85,7 @@ export default {
},
async fetchContactPersons() {
try {
const response = await axios.get('http://localhost:3000/api/contact-persons');
const response = await axios.get('/contact-persons');
this.contactPersons = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Kontaktpersonen:', error);
@@ -94,9 +94,9 @@ export default {
async saveInstitution() {
try {
if (this.editMode) {
await axios.put(`http://localhost:3000/api/institutions/${this.editId}`, this.institutionData);
await axios.put(`/institutions/${this.editId}`, this.institutionData);
} else {
const response = await axios.post('http://localhost:3000/api/institutions', this.institutionData);
const response = await axios.post('/institutions', this.institutionData);
this.institutions.push(response.data);
}
this.resetForm();
@@ -113,7 +113,7 @@ export default {
},
async deleteInstitution(id) {
try {
await axios.delete(`http://localhost:3000/api/institutions/${id}`);
await axios.delete(`/institutions/${id}`);
this.fetchInstitutions();
} catch (error) {
console.error('Fehler beim Löschen der Institution:', error);

View File

@@ -43,25 +43,25 @@ export default {
},
methods: {
async fetchPositions() {
const response = await axios.get('http://localhost:3000/api/positions');
const response = await axios.get('/positions');
this.positions = response.data;
},
async addPosition() {
if (this.editMode) {
await axios.put(`http://localhost:3000/api/positions/${this.editId}`, this.newPosition);
await axios.put(`/positions/${this.editId}`, this.newPosition);
} else {
const response = await axios.post('http://localhost:3000/api/positions', this.newPosition);
const response = await axios.post('/positions', this.newPosition);
this.positions.push(response.data);
}
this.resetForm();
await this.fetchPositions();
},
async updatePosition(position) {
await axios.put(`http://localhost:3000/api/positions/${position.id}`, position);
await axios.put(`/positions/${position.id}`, position);
this.fetchPositions(); // Refresh the list
},
async deletePosition(id) {
await axios.delete(`http://localhost:3000/api/positions/${id}`);
await axios.delete(`/positions/${id}`);
this.fetchPositions(); // Refresh the list
},
editPosition(position) {

View File

@@ -90,7 +90,7 @@ export default {
formatDate,
async fetchWorships() {
try {
const response = await axios.get('http://localhost:3000/api/worships');
const response = await axios.get('/worships');
this.worships = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Gottesdienste:', error);
@@ -98,7 +98,7 @@ export default {
},
async fetchEventPlaces() {
try {
const response = await axios.get('http://localhost:3000/api/event-places');
const response = await axios.get('/event-places');
this.eventPlaces = response.data;
} catch (error) {
console.error('Fehler beim Abrufen der Veranstaltungsorte:', error);
@@ -112,9 +112,9 @@ export default {
};
if (this.editMode) {
await axios.put(`http://localhost:3000/api/worships/${this.editId}`, payload);
await axios.put(`/worships/${this.editId}`, payload);
} else {
await axios.post('http://localhost:3000/api/worships', payload);
await axios.post('/worships', payload);
}
this.resetForm();
@@ -131,7 +131,7 @@ export default {
},
async deleteWorship(id) {
try {
await axios.delete(`http://localhost:3000/api/worships/${id}`);
await axios.delete(`/worships/${id}`);
await this.fetchWorships();
} catch (error) {
console.error('Fehler beim Löschen des Gottesdienstes:', error);