You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

50 lines
1.0 KiB

const axios = require("axios");
const basepath = process.env.API_BASE_PATH;
module.exports = {
getClients() {
return axios
.get(basepath + "/clients")
.then((res) => res.data)
.then((data) =>
data.map((client) => {
return { id: client._id, name: client.name };
})
);
},
addClient(client) {
return axios
.post(basepath + "/clients", client)
.then((res) => res.data)
.then((client) => {
return { ...client, id: client._id };
});
},
getClientById(id) {
return axios
.get(basepath + "/clients/" + id)
.then((res) => res.data)
.then((client) => {
return { ...client, id: client._id };
});
},
updateStatus(id, status) {
return axios.post(basepath + "/clients/" + id + "/events", {
eventType: "status_changed",
value: status,
});
},
deleteMany(ids) {
console.log("To delete:", ids);
return axios({
method: "delete",
url: basepath + "/clients",
data: ids,
});
},
};