Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var userArray = [
- {
- name: "John",
- email: "John@email.com"
- },
- {
- name: "Jane",
- email: "jane@email.com"
- }];
- var functionOne = function() {
- //returns Promsie object
- };
- var functionTwo = function() {
- //returns promise object
- };
- var createUser = function(user) {
- return User.findOrCreate({email: user.email},{
- name: user.name,
- email: user.email
- });
- };
- functionOne()
- .then(functionTwo)
- .each(createUser(userArray))
- .then(function onComplete() {
- console.log("Complete");
- })
- .catch(function onError() {
- console.log("Um...it's not working");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement