I'm new into programming and I have a website that talks with the backend (written in GO). I have to make the url's that are in my javascript, configurable. To be honest I really have no idea how to do this. I never heard of make url configurable before.
What is that and how I can make an url configurable? I'll also insert some code. I work with javascript, vuejs
<script>
/* eslint-disable */
export default {
name: 'listCakes',
data() {
return {
cakes: [],
errors: [],
currentPage: 1,
alerts: [],
total_cakes: 1,
cake_fields: ['id', 'purpose']
}
},
created() {
this.loadCakes(0, 10)
},
watch: {
currentPage: function (newPage) {
this.loadCakes(newPage, 10)
}
},
methods: {
newCake(evt) {
evt.preventDefault();
window.API.post('https://192.168.78.92:8000/api/v1/cake', '{}')
.then((response) => {
console.log(response.data);
this.loadCake(response.data.id)
})
.catch((error) => {
console.log(JSON.stringify(error))
})
},
editCake(record, index) {
var id = record.id
this.$router.push({ name: 'editCake', params: { id } })
},
loadCake(id) {
this.$router.push({ name: 'editCake', params: { id } })
},
loadCakes(currentPage, limit) {
if (!(Number.isInteger(currentPage) && Number.isInteger(limit))) {
currentPage = 0
limit = 10
}
var offset = (currentPage - 1) * limit
window.API.get('cake?offset=' + offset + '&limit=' + limit)
.then(response => {
this.cakes = response.data.cakes;
this.total_cakes = response.data.total;
console.log(response.data.cakes)
})
.catch(e => {
this.errors.push(e)
})
}
}
}