<template>
<form action="submit">
<label for="login">
<input type="text" id="login" v-model="username" />
</label>
<label for="password">
<input type="text" id="password" v-model="password" />
</label>
</form>
</template>
<script>
export default {
name: "login",
data() {
return {
username: "admin",
password: "123456",
};
},
methods : {
???
}
};
</script>
methods : {
sendCredentials() {
axios.post('http://URL/', {
username: this.username,
password: this.password
})
.then((response) => {
axios.defaults.headers.common.['Authorization'] = response.data.TOKEN;
})
.catch((error) => {
console.log(error);
});
},
}