Additional Info:
When clicking the “Try” script, the page goes blank, and those are the consoles ^
This is my script
function create(user, callback) {
const { Client } = require(‘pg’);
const conString = configuration.DB_URL; // Use the DB_URL from the configuration
const client = new Client({
connectionString: conString,
ssl: {
rejectUnauthorized: false // Necessary for AWS RDS, unless you configure the CA cert
}
});
client.connect(err => {
if (err) {
console.error(‘Connection error’, err.stack);
return callback(err);
}
const query = 'INSERT INTO users(email) VALUES ($1) RETURNING id';
client.query(query, [user.email], function (err, result) {
client.end(); // Make sure to close the connection after the query
if (err) {
console.error('Query error', err.stack);
return callback(err);
}
// Return the user_id as a string, Auth0 expects this format
callback(null, {
user_id: result.rows[0].id.toString()
});
});
});
}