Hi there,
Is it possible to query an external Postgres table through a Lambda function?
Because Xano Lambda functions don't support npm, could I, in theory, store the postgres library in my Xano public files and refer to the contents to execute the code below?
Would love any thoughts or help. Thanks!
const postgres = require("postgres");
async function fetchQueryData() {
const host = "XYZ";
const database = "XYZ";
const user = "XYZ";
const password = "XYZ";
const query = "XYZ";
const url = `postgres://${user}:${password}@${host}/${database}`;
const sql = postgres(url, {
ssl: "require",
});
const data = await sql`${sql.unsafe(query)}`;
return {
data,
};
}
module.exports = { fetchQueryData };