Closed AntCas closed 2 years ago
Hm, I'll take a look at this. It's possible it's not getting encoded correctly, or being tossed out.
I think it's an encoding problem, but I didn't go down the rabbit hole deep enough to find where.
Since I only currently need to make a single Airtable call I ended up going back to the vanilla airtable api and wrapping it in my own Promise to use it w/ async/await.
btw I found this project by searching "Airtable api with async await" or something similar :)
Here's my async code for the next lost engineer just trying to get async working quickly:
async function getAirtableRecordsForUser(email: string) {
const base = new Airtable({apiKey: process.env.AIRTABLE_API_KEY}).base(process.env.AIRTABLE_BASE_ID);
const promise = new Promise((resolve, reject) => {
let user_records = [];
base("TABLE_NAME")
.select({
filterByFormula: `primary_email="${email}"`
})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(record => {
user_records.push({
email: record.fields.primary_email,
address: record.fields.Address,
status: record.fields.Status
});
});
fetchNextPage();
},
function done(err) {
if (err) {
reject(err);
} else {
resolve(user_records);
}
}
);
});
try {
const response = await promise;
return response;
} catch (err) {
console.log(err);
return [];
}
}
Watch out for lack of error handling to you future engineer who copy-pastes this.
Hey there, so I pushed this into the next
branch. Can you install asyncairtable@next
and let me know if you're still having this issue?
Hey there @AntCas have you had a chance to test this on the @next
branch? Just want to be sure it's working before I merge into main.
Hey @GV14982 I won't be able to test this, apologies. Glad a fix was found!
Describe the bug Query not working on emails that include "+" character.
To Reproduce Steps to reproduce the behavior:
Expected behavior 1 record returned for the row w/ column containing the string.
Additional context
Also tried using encodeURIComponent and filterByFormula, neither worked.