Created
November 17, 2016 15:54
-
-
Save cmilfont/d3ac5321be3b50d33cfa6fa26f67f356 to your computer and use it in GitHub Desktop.
Async / Await in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const models = require('./server/models'); | |
const email = 'cmilfont@gmail.com'; | |
async function fetchData(email) { | |
const [user, kind] = await Promise.all([ | |
models.User.findOne({ | |
where: { email } | |
}), | |
models.Kind.findOne({ | |
where: { description: 'EAT' } | |
}) | |
]); | |
const activity = await models.Activity.create({ | |
UserId: user.id, | |
KindId: kind.id, | |
description: '#vaimonstro #birl #sanduba90cm', | |
secret: true | |
}); | |
return activity; | |
} | |
fetchData(email).then(activity => console.log("Gravou", activity.dataValues)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment