Created
March 9, 2024 11:08
-
-
Save idesignzone/cc63b68d5ed9a92a96d73c885b1f1301 to your computer and use it in GitHub Desktop.
Nuxt 3 - Traccar login script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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