add an axios get example

This commit is contained in:
Andreas Zweili 2021-03-20 15:08:35 +01:00
parent d97a39cd0a
commit 3e65e2d883
1 changed files with 30 additions and 1 deletions

View File

@ -2,9 +2,38 @@
<div id="dashboard">
<h1>That's the dashboard!</h1>
<p>You should only get here if you're authenticated!</p>
<p>User Email: {{ email }}</p>
</div>
</template>
<script>
import axios from "axios"
export default {
data(){
return {
email: ""
}
},
created(){
axios.get("https://axios-test-44b62-default-rtdb.europe-west1.firebasedatabase.app/users.json")
.then(response => {
console.log(response)
const data = response.data
const users = []
for (let key in data){
const user = data[key]
user.id = key
users.push(user)
}
this.email = users[0].email
console.log(users);
})
.catch(error => console.log(error))
}
}
</script>
<style scoped>
h1, p {
text-align: center;
@ -13,4 +42,4 @@
p {
color: red;
}
</style>
</style>