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
This commit is contained in:
20
frontend/src/Api.js
Normal file
20
frontend/src/Api.js
Normal file
@@ -0,0 +1,20 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user