Skip to content
Snippets Groups Projects
Commit 35bb0493 authored by moon's avatar moon
Browse files

Use apiHost and devApiHost for cms

parent 47d89158
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,8 @@
</div>
</template>
<script>
let host = require('@/components/js/const').apiHost;
export default {
name: 'ForgotPassword',
......@@ -32,14 +34,22 @@ export default {
email: '',
done: false,
error: false,
isDev: process.env.NODE_ENV === 'development',
}
},
methods: {
async forgotPassword(e) {
e.preventDefault()
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
this.done = false;
this.error = false;
this.axios.post(`http://localhost:1337/api/auth/forgot-password`, {
this.axios.post(`${host}/api/auth/forgot-password`, {
email: this.email
})
.then(() => {
......
......@@ -33,6 +33,7 @@
</div>
</template>
<script>
let host = require('@/components/js/const').apiHost;
export default {
name: 'Login',
......@@ -42,7 +43,8 @@ export default {
email: '',
password: '',
error: false,
errorMsg: `An error occurred, please try again`
errorMsg: `An error occurred, please try again`,
isDev: process.env.NODE_ENV === 'development',
}
},
computed: {
......@@ -53,8 +55,15 @@ export default {
methods: {
async login(e) {
e.preventDefault()
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
try {
const res = await this.axios.post(`http://localhost:1337/api/auth/local`, {
const res = await this.axios.post(`${host}/api/auth/local`, {
identifier: this.email,
password: this.password
});
......
......@@ -28,6 +28,8 @@
</template>
<script>
let host = require('@/components/js/const').apiHost;
export default {
name: 'ResetPassword',
data() {
......@@ -36,12 +38,20 @@ export default {
confirmPassword: '',
done: false,
error: false,
isDev: process.env.NODE_ENV === 'development',
}
},
methods: {
async resetPassword(e) {
e.preventDefault()
this.axios.post(`http://localhost:1337/api/auth/reset-password`, {
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
this.axios.post(`${host}/api/auth/reset-password`, {
code: this.$route.query.code,
password: this.password,
passwordConfirmation: this.confirmPassword
......
......@@ -35,6 +35,8 @@
</div>
</template>
<script>
let host = require('@/components/js/const').apiHost;
export default {
name: 'Register',
data() {
......@@ -44,7 +46,8 @@ export default {
password: '',
username: '',
error: false,
errorMsg: `An Error occurred, please try again`
errorMsg: `An Error occurred, please try again`,
isDev: process.env.NODE_ENV === 'development',
}
},
methods: {
......@@ -52,7 +55,14 @@ export default {
const vm = this
try {
e.preventDefault()
await vm.axios.post(`http://localhost:1337/api/auth/local/register`, {
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
await vm.axios.post(`${host}/api/auth/local/register`, {
name: vm.name,
password: vm.password,
email: vm.email,
......
......@@ -169,6 +169,7 @@
</div>
</template>
<script>
let host = require('@/components/js/const').apiHost;
export default {
name: 'UpdateItem',
......@@ -194,7 +195,8 @@ export default {
syncResponse: '', // response from the sync process (errors if any)
loaded: false,
error: false,
errorMsg: `An error occurred, please try again`
errorMsg: `An error occurred, please try again`,
isDev: process.env.NODE_ENV === 'development',
}
},
computed: {
......@@ -210,9 +212,14 @@ export default {
},
methods: {
async update(e) {
const vm = this;
e.preventDefault()
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
const jwt = vm.jwt;
if(jwt === null) {
vm.loaded = false;
......@@ -237,7 +244,7 @@ export default {
try {
if(vm.item !== 'new') {
const res = await this.axios.put(`http://localhost:1337/api/update-items/` + vm.item, {
const res = await this.axios.put(`${host}/api/update-items/` + vm.item, {
data: dat,
}, {
headers: {
......@@ -245,7 +252,7 @@ export default {
}
});
} else {
const res = await this.axios.post(`http://localhost:1337/api/update-items`, {
const res = await this.axios.post(`${host}/api/update-items`, {
data: dat,
}, {
headers: {
......@@ -267,6 +274,10 @@ export default {
async load(id) {
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
const jwt = vm.jwt;
if(jwt === null) {
vm.loaded = false;
......@@ -276,7 +287,7 @@ export default {
// console.log(vm.userData)
try {
const res = await this.axios.get(`http://localhost:1337/api/update-items/` + id, {
const res = await this.axios.get(`${host}/api/update-items/` + id, {
headers: {
Authorization: `Bearer ${jwt}`
}
......@@ -315,6 +326,10 @@ export default {
async updateReview() {
const vm = this;
if(vm.isDev) {
host = require('@/components/js/const').devApiHost;
}
const jwt = vm.jwt;
if(jwt === null) {
vm.loaded = false;
......@@ -329,7 +344,7 @@ export default {
};
try {
await this.axios.put(`http://localhost:1337/api/update-item/review/` + vm.item, {
await this.axios.put(`${host}/api/update-item/review/` + vm.item, {
data: dat,
}, {
headers: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment