I'm using Airtable db to fetch data against an input. I want to fetch data from database against that input but I'm not aware how to achieve that.
Here's my fetch API call function
const fetchData = async e => {
e.preventDefault();
fetch(`https://api.airtable.com/v0/${process.env.AIRTABLE_BASE_ID}/${process.env.AIRTABLE_TABLE_NAME}`, {
method: 'GET',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: `Bearer ${process.env.API_KEY}`,
},
})
.then(response => {
if (response.ok) {
return response.json();
} else {
throw new Error('Something went wrong');
}
})
.then(rawResponse => {
console.log(rawResponse);
})
.catch(error => {
customToast.error('Something went wrong.');
console.log('Error', error);
});
};