Skip to content
This repository has been archived by the owner on May 28, 2021. It is now read-only.

Commit

Permalink
rewrite logic for async await
Browse files Browse the repository at this point in the history
  • Loading branch information
M0nica committed May 1, 2021
1 parent 746a0d4 commit 202f704
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions functions/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@ exports.handler = async function(event) {

if (!name || !city) {
console.error(err)
return
return {
statusCode: 500,
body: `Something went wrong. Double check if you sent a valid name and city.`
}
}

try {
await base(process.env.AIRTABLE_TABLE).create(
{
return await base(process.env.AIRTABLE_TABLE)
.create({
name: name,
city: city,
ghLink: github
},
(err, record) => {
if (err) {
console.error(err)
return
})
.then(record => {
return {
statusCode: 200,
body: `Successfully added ${event.queryStringParameters.name}. document ID is ${record.id}`
}
console.log(`Human was created, document ID is ${record.getId()}`)
}
)
return {
statusCode: 200,
body: `Successfully added ${event.queryStringParameters.name}`
}
} catch (err) {
})
} catch {
return {
statusCode: 500,
body: JSON.stringify(err.message)
body: `Something went wrong`
}
}
}

0 comments on commit 202f704

Please sign in to comment.