src/aws.js
function sendAWSRequest(req) {
  return new Promise((resolve, reject) => {
    const send = new AWS.NodeHttpClient()
    send.handleRequest(req, null, (res) => {
      let body = ''
      res.on('data', (chunk) => {
        body += chunk
      })
      res.on('end', () => {
        const { headers, statusCode } = res
        resolve({ body, headers, statusCode })
      })
      res.on('error', (err) => {
        console.log(`Error: ${err}`)
        reject(err)
      })
    }, (err) => {
      console.log(`Error: ${err}`)
      reject(err)
    })
  })
}
function sendAWSRequest(req) {
  return new Promise((resolve, reject) => {
    const send = new AWS.NodeHttpClient()
    send.handleRequest(req, null, (res) => {
      let body = ''
      res.on('data', (chunk) => {
        body += chunk
      })
      res.on('end', () => {
        const { headers, statusCode } = res
        resolve({ body, headers, statusCode })
      })
      res.on('error', (err) => {
        console.log(`Error: ${err}`)
        reject(err)
      })
    }, (err) => {
      console.log(`Error: ${err}`)
      reject(err)
    })
  })
}
function sendAWSRequest ( req ) { return new Promise ( ( resolve , reject ) => { const send = new AWS . NodeHttpClient ( ) send . handleRequest ( req , null , ( res ) => { let body = '' res . on ( 'data' , ( chunk ) => { body += chunk } ) res . on ( 'end' , ( ) => { const { headers , statusCode } = res resolve ( { body , headers , statusCode } ) } ) res . on ( 'error' , ( err ) => { console . log ( ` ${ err } ` ) reject ( err ) } ) } , ( err ) => { console . log ( ` ${ err } ` ) reject ( err ) } ) } ) }
AWS HTTP request handler
@param {String} req - signed aws request
@return {Promise}
AWS HTTP request handler