尝试使用无服务器获取 aws lambda
trying to fetch on aws lambda using serverless
我正在尝试 运行 AWS Lambda 上的一个简单脚本,使用无服务器推送它,该脚本获取 url 和 returns 它(代理),对于一些原因是我看不到回复。
有问题的脚本:
'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,
}),
}
};
我的无服务器 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
解决方案是在 JSON.stringify
中将 res
更改为 res.data
我正在尝试 运行 AWS Lambda 上的一个简单脚本,使用无服务器推送它,该脚本获取 url 和 returns 它(代理),对于一些原因是我看不到回复。
有问题的脚本:
'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,
}),
}
};
我的无服务器 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
解决方案是在 JSON.stringify
中将res
更改为 res.data