Send Change Password Email from Post-User Registration Action

Problem statement

Are there any Action samples that show how to send a change password email after a user signs up?

Solution

The following Post-User-Registration Action code will send a change password email once a user signs up:

exports.onExecutePostUserRegistration = async (event, api) => {
  var axios = require("axios").default;

  const sendPasswordResetEmail = () => {
    var options = {
      method: 'POST',
      url: 'https://YOUR_DOMAIN}/dbconnections/change_password',
      headers: {'content-type': 'application/json'},
      data: {
        client_id: 'event.client.client_id',
        email: 'event.user.email',
        connection: 'event.connection.name'
        
      }
    };
    try{
    axios.request(options).then(function (response) {
      console.log("Response: ",response.data);
    })
    }catch(error){
      console.error(error)
    }
  }

}