Created
October 16, 2020 18:27
-
-
Save boring-dragon/0d825f180e3e11a6fef8d184b44a38bf to your computer and use it in GitHub Desktop.
Baivaru api direct test
This file contains hidden or 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
| <!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