added repo for API access, still strange error in Group.vue

This commit is contained in:
Tobias Kurze
2019-04-10 15:16:20 +02:00
parent c043918fb8
commit 654c78ff7c
5 changed files with 259 additions and 13 deletions

View File

@@ -1,12 +1,12 @@
// Repository.js
import Vue from 'vue';
import Vue from "vue";
import axios from "axios";
import store from "@/store";
const baseDomain = "http://localhost:5443";
const API_URL = `${baseDomain}/api/v1`;
export default axios.create({
API_URL,
headers: { headers: { Authorization: `Bearer ${jwt}` } },
baseURL: API_URL, headers: { Authorization: `Bearer ${store.state.access_token}` },
});

View File

@@ -0,0 +1,11 @@
// RepositoryFactory.js
import GroupRepository from "./groupRepository";
const repositories = {
group: GroupRepository,
};
export const RepositoryFactory = {
get: name => repositories[name],
};

View File

@@ -0,0 +1,19 @@
// groupRepository.js
import Repository from "./Repository";
const resource = "/group";
export default {
get() {
return Repository.get(`${resource}`);
},
getGroup(groupId) {
return Repository.get(`${resource}/${groupId}`);
},
createGroup(groupData) {
return Repository.post(`${resource}`, groupData);
},
};