-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes
49 lines (47 loc) · 1.5 KB
/
notes
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
45
46
47
48
49
const deleteMeasure = async (data) => {
await axios({
url: `http:https://localhost:3001/measurements/${data.measurement_id}/measures/${data.id}/`,
method: "DELETE",
headers: {
Authorization: `Basic ${userToken}`,
},
})
// .then(function (response) {
// const updatedMeasurements = measurements.map((obj) => {
// if (obj.id === data.measurement_id) {
// const index = obj.measures.map((el) => el.id).indexOf(data.id);
// obj.measures.splice(index, 1);
// }
// return obj;
// });
// setMeasurements(updatedMeasurements);
// })
.then(function (response) {
setFetchRequested(!fetchRequested);
})
.catch(function (error) {
console.log(error);
});
};
const addMeasure = async (data) => {
await axios({
url: `http:https://localhost:3001/measurements/${data.id}/measures`,
data: { value_of_measure: "321", measurement_id: data.id },
method: "POST",
headers: {
Authorization: `Basic ${userToken}`,
},
})
// .then(function (response) {
// const updatedMeasurements = measurements.map(
// (obj) => [response.data].find((o) => o.id === obj.id) || obj
// );
// setMeasurements(updatedMeasurements);
// })
.then(function (response) {
setFetchRequested(!fetchRequested);
})
.catch(function (error) {
return error;
});
};