2018年3月22日 星期四

aws lambda 只有isomorphic-fetch傳上去可以正常跑出來

'use strict';

const fetch = require('isomorphic-fetch');


module.exports.hello = (event, context, callback) => {

fetch('https://xxxx/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `
{
}
` }),
})
.then(res => res.json())
.then(res => console.log(res.data));
const response = {
statusCode: 200,
body: JSON.stringify({
message: 'Go Serverless v1.0! Your function executed successfully!',
input: event,
}),
};

callback(null, response);

// Use this code if you don't use the http event with the LAMBDA-PROXY integration
// callback(null, { message: 'Go Serverless v1.0! Your function executed successfully!', event });
};

沒有留言:

張貼留言