Skip to content

Commit

Permalink
Move rootUrl constant to http utils
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w committed Jun 25, 2019
1 parent 47e54e4 commit eb93a43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/server/static/components/http.js
Expand Up @@ -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 changes: 6 additions & 7 deletions app/server/static/components/projects.vue
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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 = '';
Expand Down

0 comments on commit eb93a43

Please sign in to comment.