Skip to content

Commit

Permalink
feat(front): use fetch instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Inerska committed Mar 10, 2024
1 parent 88ae862 commit 7650ccf
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions talent-hub_website/pages/missions/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,21 @@ const apiBaseUrl = config.public.apiBaseUrl;
async function loadJobs() {
loading.value = true;
try {
console.log("apiBaseUrl", apiBaseUrl)
const {data: missions, pending, error, refresh } = await useFetch(`${apiBaseUrl}/missions`, {
onRequestError({ request, options, error }) {
console.log(error);
},
});
if (missions.value) {
console.log("missions", missions.value)
visibleJobs.value = missions.value;
allJobsLoaded.value = true;
} else {
console.error("no missions empty");
visibleJobs.value = [];
}
} catch (error) {
console.log("apiBaseUrl", apiBaseUrl)
fetch(`${apiBaseUrl}/missions`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}).then(response => response.json()).then(data => {
console.log("data", data)
visibleJobs.value = data;
allJobsLoaded.value = true;
}).catch(error => {
console.error("no missions", error);
toast.error('Une erreur est survenue lors du chargement des offres');
visibleJobs.value = [];
}
});
loading.value = false;
}
Expand Down

0 comments on commit 7650ccf

Please sign in to comment.