Skip to content

Commit c2fbe77

Browse files
committed
Move rootUrl constant to http utils
1 parent 89dceaa commit c2fbe77

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/server/static/components/http.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ const HTTP = axios.create({
77
baseURL: `/v1/${baseUrl}`,
88
});
99

10+
export const rootUrl = window.location.href.split('/').slice(0, 3).join('/');
1011
export const newHttpClient = axios.create;
1112
export default HTTP;

app/server/static/components/projects.vue

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@
120120

121121
<script>
122122
import { title, daysAgo } from './filter';
123-
import { newHttpClient } from './http';
123+
import { rootUrl, newHttpClient } from './http';
124124
125-
const baseUrl = window.location.href.split('/').slice(0, 3).join('/');
126125
const httpClient = newHttpClient();
127126
128127
export default {
@@ -153,8 +152,8 @@ export default {
153152
154153
created() {
155154
Promise.all([
156-
httpClient.get(`${baseUrl}/v1/projects`),
157-
httpClient.get(`${baseUrl}/v1/me`),
155+
httpClient.get(`${rootUrl}/v1/projects`),
156+
httpClient.get(`${rootUrl}/v1/me`),
158157
]).then(([projects, me]) => {
159158
this.items = projects.data;
160159
this.username = me.data.username;
@@ -164,7 +163,7 @@ export default {
164163
165164
methods: {
166165
deleteProject() {
167-
httpClient.delete(`${baseUrl}/v1/projects/${this.project.id}`).then(() => {
166+
httpClient.delete(`${rootUrl}/v1/projects/${this.project.id}`).then(() => {
168167
this.isDelete = false;
169168
const index = this.items.indexOf(this.project);
170169
this.items.splice(index, 1);
@@ -198,9 +197,9 @@ export default {
198197
guideline: 'Please write annotation guideline.',
199198
resourcetype: this.resourceType(),
200199
};
201-
httpClient.post(`${baseUrl}/v1/projects`, payload)
200+
httpClient.post(`${rootUrl}/v1/projects`, payload)
202201
.then((response) => {
203-
window.location = `${baseUrl}/projects/${response.data.id}/docs/create`;
202+
window.location = `${rootUrl}/projects/${response.data.id}/docs/create`;
204203
})
205204
.catch((error) => {
206205
this.projectTypeError = '';

0 commit comments

Comments
 (0)