Progress so far
All checks were successful
the build was successful

This commit is contained in:
konrad 2019-02-19 22:54:42 +01:00
parent a2ae7a6d31
commit 70b382c18a
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 15 additions and 4 deletions

View File

@ -1 +1 @@
export const URL_PREFIX = '/api/v1/'
export const URL_PREFIX = '/api/v1' // _without_ slash at the end

View File

@ -1,5 +1,8 @@
import {Model} from 'vue-mc'
import {URL_PREFIX} from './config'
let config = require('../../public/config.json')
import {reduce, replace} from 'lodash'
export class List extends Model {
// Default attributes that define the "empty" state.
@ -23,15 +26,23 @@ export class List extends Model {
methods: {
update: 'POST',
create: 'PUT',
},
// How to add headers to requests?
headers: {
'Authorization': 'Bearer ' + localStorage.getItem('token')
}
}
}
getRouteResolver() {
let self = this
return function (value, options) {
// eslint-disable-next-line
console.log(value, options)
return URL_PREFIX + value
let replacements = self.getRouteReplacements(value, options); // Replace all route parameters with their replacement values.
let replaced = reduce(replacements, function (result, value, parameter) {
return replace(result, parameter, value);
}, value)
return config.VIKUNJA_API_BASE_URL + URL_PREFIX + replaced
}
}