how to use api in vue js code example
Example 1: vue fetch api
async created() {
const response = await fetch("https://api.npms.io/v2/search?q=vue");
const data = await response.json();
this.totalVuePackages = data.total;
}
Example 2: how to use api url in vue
<a :href="post.url" target="_blank"><img :src="post.image_url"></a>
Example 3: import api vue and html
new Vue({
el: '#app',
data () {
return {
info: null
}
},
mounted () {
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => (this.info = response))
}
})