title: Netlify Lambda Functions
body: <p>I am having an issue getting a 502 error back when I call my Netlify function. Is there something I am doing wrong in my Axios call or does the "error" sent in the callback need to be an actual Error object?</p>
  
  <p>Below is the example of my function:</p>
  
  <pre><code>const axios = require('axios')
  require('dotenv').config()
  const https = require('https')
  const headers = {
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Headers': 'Content-Type'
  }
  
  exports.handler = function (event, context, callback) {
    // your server-side functionality
  
    axios
      .post(
        `https://us18.api.mailchimp.com/3.0/lists/${
          process.env.LIST_ID
        }/members/`, {
          email_address: 'deuce3608@gmail.com',
          status: 'subscribed'
        }, {
          auth: {
            username: 'admin',
            password: process.env.MAILCHIMP_API_KEY
          }
        }
      )
      .then(response =&gt; {
        callback(null, {
          statusCode: 200,
          headers,
          body: response.data
        })
      })
      .catch(err =&gt; {
        callback(JSON.stringify(err.response.data))
      })
  }
  </code></pre>