Skip to content

Instantly share code, notes, and snippets.

@idesignzone
Created March 9, 2024 11:08
Show Gist options
  • Save idesignzone/cc63b68d5ed9a92a96d73c885b1f1301 to your computer and use it in GitHub Desktop.
Save idesignzone/cc63b68d5ed9a92a96d73c885b1f1301 to your computer and use it in GitHub Desktop.
Nuxt 3 - Traccar login script
<template>
</template>
<script setup>
const config = useRuntimeConfig();
const credentials = reactive({
email: undefined,
password: undefined,
});
function onSubmit() {
const formData = new URLSearchParams();
formData.append("email", credentials.email);
formData.append("password", credentials.password);
$fetch(config.public.traccarServer + "/api/session", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
body: formData,
})
.then(function (res) {
// Do something with response data
console.log(res);
})
.catch((error) => {
console.error("There was a problem with Login:", error);
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment