Browse Source

Move rootUrl constant to http utils

pull/258/head
Clemens Wolff 5 years ago
parent
commit
c2fbe77447
2 changed files with 7 additions and 7 deletions
  1. 1
      app/server/static/components/http.js
  2. 13
      app/server/static/components/projects.vue

1
app/server/static/components/http.js

@ -7,5 +7,6 @@ const HTTP = axios.create({
baseURL: `/v1/${baseUrl}`,
});
export const rootUrl = window.location.href.split('/').slice(0, 3).join('/');
export const newHttpClient = axios.create;
export default HTTP;

13
app/server/static/components/projects.vue

@ -120,9 +120,8 @@
<script>
import { title, daysAgo } from './filter';
import { newHttpClient } from './http';
import { rootUrl, newHttpClient } from './http';
const baseUrl = window.location.href.split('/').slice(0, 3).join('/');
const httpClient = newHttpClient();
export default {
@ -153,8 +152,8 @@ export default {
created() {
Promise.all([
httpClient.get(`${baseUrl}/v1/projects`),
httpClient.get(`${baseUrl}/v1/me`),
httpClient.get(`${rootUrl}/v1/projects`),
httpClient.get(`${rootUrl}/v1/me`),
]).then(([projects, me]) => {
this.items = projects.data;
this.username = me.data.username;
@ -164,7 +163,7 @@ export default {
methods: {
deleteProject() {
httpClient.delete(`${baseUrl}/v1/projects/${this.project.id}`).then(() => {
httpClient.delete(`${rootUrl}/v1/projects/${this.project.id}`).then(() => {
this.isDelete = false;
const index = this.items.indexOf(this.project);
this.items.splice(index, 1);
@ -198,9 +197,9 @@ export default {
guideline: 'Please write annotation guideline.',
resourcetype: this.resourceType(),
};
httpClient.post(`${baseUrl}/v1/projects`, payload)
httpClient.post(`${rootUrl}/v1/projects`, payload)
.then((response) => {
window.location = `${baseUrl}/projects/${response.data.id}/docs/create`;
window.location = `${rootUrl}/projects/${response.data.id}/docs/create`;
})
.catch((error) => {
this.projectTypeError = '';

Loading…
Cancel
Save