Files
EIST-Teamprojekt/frontend/src/Api.js
cato f6385b40f6 Proof of concept (#6)
* Sample template created

* added findByName functionality for item

* Solve Cors errors and inhibit DefaultExposure

* changed project structure

* Added frontend

* Creation of base template (#1)

* changed base path of REST api and updated frontend api quering
2022-06-02 19:11:46 +02:00

20 lines
545 B
JavaScript

import axios from 'axios'
const SERVER_URL = 'http://localhost:9000'
const instance = axios.create({
baseURL : SERVER_URL,
timeout: 1000
})
export default {
createNew: (name, quantity, unit) => instance.post("/api/v1/items", {name: name, quantity : quantity, unit : unit}),
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)
}