Skip to content

Instantly share code, notes, and snippets.

@boring-dragon
Created October 16, 2020 18:27
Show Gist options
  • Save boring-dragon/0d825f180e3e11a6fef8d184b44a38bf to your computer and use it in GitHub Desktop.
Save boring-dragon/0d825f180e3e11a6fef8d184b44a38bf to your computer and use it in GitHub Desktop.
Baivaru api direct test
<!DOCTYPE html>
<html>
<head>
<title>Baivaru Dhivatar Vue component Implementation</title>
</head>
<body>
<div id="app">
<baivaru-dhivatar name="ޖިނާސް"></baivaru-dhivatar>
<baivaru-dhivatar name="އަތްފާން"></baivaru-dhivatar>
</div>
<script type="text/x-template" id="baivaru-dhivatar-template">
<img :src="image" alt="avatar">
</script>
<!-- Import Vue.js and axios -->
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
Vue.component('baivaru-dhivatar', {
template: '#baivaru-dhivatar-template',
props: {
name: {
type: String,
required: true
}
},
data() {
return {
image: ""
}
},
created() {
axios.get(`https://dhivatars.baivaru.net/api/?name=${this.name}`)
.then(response => {
this.image = response.data;
})
}
})
new Vue({
el: '#app'
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment