Hey everyone! I’m working on a project where I need to display data from Airtable using Vue.js. I’ve got the basic setup working, but I’m stuck on how to properly format the URL fields.
Here’s what I’ve tried so far:
<div id="app">
<ul>
<li v-for="record in records">
<h3>{{ record.fields.Name }}</h3>
<a :href="record.fields.Website.url" v-if="record.fields.Website">
<p>Description: {{ record.fields.Description }}</p>
</a>
<p>
<strong>Website: </strong>
{{ record.fields.Website }}
</p>
</li>
</ul>
</div>
And the Vue.js part:
new Vue({
el: "#app",
data: {
records: []
},
created() {
this.fetchData();
},
methods: {
fetchData() {
const apiKey = 'your-api-key';
const baseId = 'your-base-id';
axios.get(`https://api.airtable.com/v0/${baseId}/TableName`, {
headers: { Authorization: `Bearer ${apiKey}` }
})
.then(response => {
this.records = response.data.records;
})
.catch(error => console.error(error));
}
}
});
The data is showing up, but the URL fields aren’t formatting correctly as clickable links. Any ideas on how to fix this? Thanks!