Files
WebETA/src/composables/useAttachments.js
Alexandro Uc Santos cea26e1f6e add: Form create load
2023-12-07 18:04:17 -06:00

30 lines
785 B
JavaScript

import { ref } from "vue";
import { useLoadsStore } from "../stores/loads";
import api from "../lib/axios";
export default function useAttachments() {
const loading = ref(false);
const attachments = ref(null);
const loadStore = useLoadsStore();
const getAttachmentLoad = async() => {
try {
loading.value = true;
const endpoint = "/v1" + "/load-attachments/load/" + loadStore.currentLoad._id;
const {data} = await api.get(endpoint);
attachments.value = data;
} catch (error) {
attachments.value = null;
console.log(error);
} finally {
loading.value = false;
}
}
return {
getAttachmentLoad,
loading,
attachments
}
}