I’m working on a Vue.js app that fetches data from Airtable using axios. My current setup works fine for getting basic table data, but I’m running into issues with linked records. In my main table, I have a field called “COMPANY” that connects to another table with details like “COMPANY_NAME” and “BUSINESS_TYPE”. When I try to access the nested data from the linked table, I get errors or undefined values. I think I need to make multiple API calls, maybe using axios.all(), but I’m not sure how to structure it properly. Has anyone dealt with this before?
const app = new Vue({
el: '#main-app',
data: {
greeting: 'Hello from Vue',
records: []
},
mounted() {
this.fetchRecords();
},
methods: {
fetchRecords() {
const baseId = 'appXYZ123456789';
const apiToken = 'keyABC987654321';
axios.get(`https://api.airtable.com/v0/${baseId}/PROJECTS?api_key=${apiToken}`, {
headers: { Authorization: `Bearer ${apiToken}` }
})
.then(response => {
this.records = response.data.records;
})
.catch(err => {
console.error(err);
});
}
}
});
<div id="main-app">
<h1>{{greeting}}</h1>
<div v-for="(record, idx) in records" :key="idx">
<div class="record-card">
<p><strong>Start Date:</strong> {{ record.fields['START_DATE'] }}</p>
<p><strong>Description:</strong> {{ record.fields['DESCRIPTION'] }}</p>
<p><strong>Priority:</strong> {{ record.fields['PRIORITY'] }}</p>
<p><strong>Company:</strong> {{ record.fields['COMPANY'] }}</p>
<!-- This line causes issues -->
<p><strong>Company Name:</strong> {{ record.fields['COMPANY']['COMPANY_NAME'] }}</p>
</div>
</div>
</div>