const fetch = require('node-fetch')
const { Core } = require('@adobe/aio-sdk')
const { errorResponse, stringParameters, checkMissingRequestInputs } = require('../utils')
const sftpClient = require('ssh2-sftp-client');
// main function that will be executed by Adobe I/O Runtime
async function main(params) {
// create a Logger
const logger = Core.Logger('main', { level: params.LOG_LEVEL || 'info' })
let sftp = new sftpClient();
try {
// 'info' is the default level if not set
logger. info('Calling the main action')
// log parameters, only if params.LOG_LEVEL === 'debug'
logger.debug(stringParameters(params))
//Check for missing request input parameters and headers
const requiredParams = ['host', 'port', 'username', 'password']
const requiredHeaders = []
const errorMessage = checkMissingRequestInputs(params, requiredParams, requiredHeaders)
if (errorMessage) {
// return and log client errors
return errorResponse(400, errorMessage, logger)
}
const options = {
host: params.host,
port: params.port,
username: params.username,
password: params.password
};
sftp.connect(options).then(() => {
console.log('Connected');
return sftp.list('/');
}).then((data) => {
console.log('Then', data);
}).catch((err) => {
console.log(err, 'catch error');
});
even after using the right port username and password, I am getting this error
I checked the same code with the node.js locally and it is working fine