0

I'm using const instead of var.

const allUsers = Users.find().fetch();

if (allUsers.length === 0) {
  createDummyUsers();
  // I want to say allUsers = createDummyUsers(); instead but allUsers is const and it's async
}

The problem is I can't reassign allUsers (if length === 0) because it's a const. What's the convention to call an async function and await the response here? This is the function I'm trying to wait for:

const createDummyUsers = function () {
  console.log('// seeding users…');
  createUser('Bruce', 'dummyuser1@telescopeapp.org');
  createUser('Arnold', 'dummyuser2@telescopeapp.org');
  createUser('Julia', 'dummyuser3@telescopeapp.org');
};
Tyler L
  • 835
  • 2
  • 16
  • 28

0 Answers0