const axios = require('axios');const REQUEST_TIMEOUT = 2000; // Example timeout/*** Handler that will be called during the execution of a PreUserRegistration flow.** @param {Event} event - Details about the context and user that is attempting to register.* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.*/exports.onExecutePreUserRegistration = async (event, api) => { try { // Set a secret USER_SERVICE_URL = 'https://yourservice.com' const remoteUser = await axios.get(event.secrets.USER_SERVICE_URL, { timeout: REQUEST_TIMEOUT, params: { email: event.user.email } }); if (remoteUser) { api.user.setAppMetadata('my-api-user-id', remoteUser.id); } } catch (err) { api.validation.error('custom_error', 'Custom Error'); }};