Skip to content

Commit

Permalink
Simplify airCreate
Browse files Browse the repository at this point in the history
Though passing an array of records to create was mandatory
  • Loading branch information
maxwofford committed Sep 18, 2019
1 parent ec7c247 commit 2f54440
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ export const airCreate = (baseName, fields) =>
console.log(
`I'm asking Airtable to create a new record in the ${baseName} base at ${timestamp}`
)
base(baseName).create([{ fields }], (err, records) => {
base(baseName).create({ fields }, (err, record) => {
if (err) {
reject(err)
}
if (!records[0]) {
if (!record) {
reject(new Error('Record not created'))
}
console.log(
`Airtable saved my ${baseName} record from ${timestamp} in ${Date.now() -
timestamp}ms`
)
resolve(records[0])
resolve(record)
})
})

Expand Down

0 comments on commit 2f54440

Please sign in to comment.