diff --git a/src/services/Api.js b/src/services/Api.js index f294d4af..ad18db50 100644 --- a/src/services/Api.js +++ b/src/services/Api.js @@ -3,7 +3,7 @@ import axios from 'axios' export default() => { return axios.create({ baseURL: `http://127.0.0.1:8000/api/`, - baseURL: `https://api.account.keks.cloud/api/`, + //baseURL: `https://api.account.keks.cloud/api/`, withCredentials: false, headers: { 'Accept': 'application/json', diff --git a/src/services/Apps.js b/src/services/Apps.js index 70494f8b..180d7930 100644 --- a/src/services/Apps.js +++ b/src/services/Apps.js @@ -29,6 +29,6 @@ export default { return Api().get('/v1/app/'+id+'/user') }, newApp(name, description, url) { - return Api().post('/v1/app/', {name: name, description: description, url: url}); + return Api().post('/v1/app', {name: name, description: description, url: url}); } } \ No newline at end of file diff --git a/src/views/NewApp.vue b/src/views/NewApp.vue index cc82283f..e3538864 100644 --- a/src/views/NewApp.vue +++ b/src/views/NewApp.vue @@ -10,7 +10,8 @@ type="text" v-model="name" error=true - error-messages="ja" + :error=nameErrorFlag + :error-messages=nameError > @@ -50,13 +53,45 @@ data () { return { name: '', + nameError: null, + nameErrorFlag: false, description: '', - url: '' + descriptionError: '', + descriptionErrorFlag: false, + url: '', + urlError: '', + urlErrorFlag: false } }, methods: { createApp: function () { - AppService.newApp() + this.nameErrorFlag = false; + this.nameError = null; + this.descriptionErrorFlag = false; + this.descriptionError = null; + this.urlErrorFlag = false; + this.urlError = null; + AppService.newApp(this.name, this.description, this.url).then((res) => { + this.$router.push({name: 'appDetails', params: {id: res.data.data.id}}); + }).catch((error) => { + if(error.response.status == 422){ + if(error.response.data.data.name != undefined) { + this.nameErrorFlag = true; + this.nameError = error.response.data.data.name[0] + } + if(error.response.data.data.description != undefined) { + this.descriptionErrorFlag = true; + this.descriptionError = error.response.data.data.description[0] + } + if(error.response.data.data.url != undefined) { + this.urlErrorFlag = true; + this.urlError = error.response.data.data.url[0] + } + console.log(error.response.data.data); + } else { + alert(error.response.data.msg); + } + }); } }, mounted: function() {