-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patharmazenamentoHttp.js
More file actions
44 lines (39 loc) · 867 Bytes
/
armazenamentoHttp.js
File metadata and controls
44 lines (39 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function Armazenamento(urlBase) {
urlBase = urlBase || "http://matrix.avalie.net/api/participantes";
function adicionar(item) {
return axios
.post(urlBase, item)
.then(res => {
return res.data;
})
.catch(error => {
throw error.response.data.message;
});
}
function atualizar(item) {
return axios
.put(urlBase + "/" + item.id, item)
.then(res => {
return res.data;
})
.catch(error => {
throw error.response.data.message;
});
}
function remover(id) {
return axios.delete(urlBase + "/" + id).then(res => res.data);
}
function obterTodosOsItens() {
return axios.get(urlBase).then(res => {
return res.data;
});
}
return {
adicionar,
remover,
atualizar,
//obterItem,
//obterItens,
obterTodosOsItens
};
}