dutzi
dutzi

Reputation: 1928

trying to fetch on aws lambda using serverless

I'm trying to run a simple script on AWS Lambda using Serverless to push it, the script fetches a url and returns it (a proxy), for some reason I can't see the response.

The script in question:

'use strict';
let axios = require('axios')

module.exports.hello = async (event, context) => {
  let res = await axios.get('http://example.com')
  return {
    statusCode: 200,
    body: JSON.stringify({
      message: res,
      input: event,
    }),
  }
};

My serverless YML:

service: get-soundcloud-tracks 
provider:
  name: aws
  runtime: nodejs8.10
  profile: home
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: users/create
          method: get
          cors: true

Upvotes: 1

Views: 2051

Answers (1)

dutzi
dutzi

Reputation: 1928

The solution was changing res to res.data inside the JSON.stringify

Upvotes: 1

Related Questions