- [API] Segregated API files, Implemented spells-list, component that calls the API

This commit is contained in:
Alexis
2020-04-06 16:39:55 +02:00
parent 37f4913d3e
commit 042c205ce4
11 changed files with 169 additions and 29 deletions

7
client/api/api.js Normal file
View File

@@ -0,0 +1,7 @@
import axios from "axios"
const url = "http://localhost:2814/api"
export default axios.create({
baseURL: url
})

View File

@@ -0,0 +1,11 @@
import spellsRepository from './spellsRepository'
// List of possible repositories
const repositories = {
spells: spellsRepository
}
// Usage : RepositoryFactoryInstance.get('reponame');
export const RepositoryFactory = {
get: name => repositories[name]
}

View File

@@ -0,0 +1,14 @@
import api from './api'
// URL for spells
const resource = "/spells"
// CRUD methods for spells
export default {
getSpells() {
return api.get(`${resource}`)
},
getSpell(id) {
return api.get(`${resource}?id=${id}`)
},
}