TLDR: Use for...of instead of forEach() in asynchronous code.
For legacy browsers, use for(...;...;...) or [].reduce()
To execute the promises in parallel, use Promise.all([].map(...))
| /** | |
| * Handler that will be called during the execution of a PostLogin flow. | |
| * | |
| * @param {Event} event - Details about the user and the context in which they are logging in. | |
| * @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. | |
| */ | |
| exports.onExecutePostLogin = async (event, api) => { | |
| const axios = require("axios"); | |
| const ManagementClient = require("auth0").ManagementClient; |
| const admin = require('firebase-admin'); | |
| const fs = require('fs'); | |
| const serviceAccount = require('../../../../../../Private/myschool-data_transfer-key.json'); | |
| admin.initializeApp({ credential: admin.credential.cert(serviceAccount) }); | |
| const schema = require('./schema').schema; | |
| const firestore2json = (db, schema, current) => { |