changed base path of REST api and updated frontend api quering
This commit is contained in:
@@ -10,7 +10,11 @@ const instance = axios.create({
|
||||
export default {
|
||||
createNew: (name, quantity, unit) => instance.post("/api/v1/items", {name: name, quantity : quantity, unit : unit}),
|
||||
|
||||
getAll: () => instance.get('/api/v1/items'),
|
||||
getAll: () => instance.get('/api/v1/items', {
|
||||
transformResponse: [function (data) {
|
||||
return data? JSON.parse(data)._embedded.items : data;
|
||||
}]
|
||||
}),
|
||||
|
||||
removeForId: (id) => instance.delete('/api/v1/items/'+ id)
|
||||
}
|
||||
@@ -84,14 +84,14 @@
|
||||
|
||||
api.createNew(components[0],
|
||||
parseInt(components[1].replace ( /[^\d.]/g, '' )),
|
||||
components[1].replace(/[0-9]/g, ''))
|
||||
.then( (response) => {
|
||||
components[1].replace(/[0-9]/g, '') === 'ml' ? 'MILLILETERS' : "GRAMMS"
|
||||
).then( (response) => {
|
||||
this.$log.debug("New item created:", response);
|
||||
this.items.push({
|
||||
id: response.data.id,
|
||||
name: components[0],
|
||||
quantity: parseInt(components[1].replace ( /[^\d.]/g, '' )),
|
||||
unit: components[1].replace(/[0-9]/g, '')
|
||||
unit: components[1].replace(/[0-9]/g, '') === 'MILLILETERS' ? 'ml' : 'g'
|
||||
})
|
||||
}).catch((error) => {
|
||||
this.$log.debug(error);
|
||||
|
||||
Reference in New Issue
Block a user