I am trying to enable CORS header on my Lambda/Node JS function. I have tried to enable CORS in the API gateway but that us not working. Any idea's, My nodeJS/Lambda function code is as follows:
exports.handler = async (event) => {
if (event.httpMethod === 'GET') {
return getData(event);
}
};
const getData = event => {
let data = {
"home": [{
"title": "John Doe title",
"body": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
"image": "image/example.jpg"
}
],
"about": [{
"title": "John is the main part 1",
"body": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.",
"image": "image/example.jpg"
}
]
};
return {
statusCode: 200,
body: JSON.stringify(data, null, 2)
};
};