You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

27 lines
529 B

const sendJson = async getData => {
try {
return {
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Cache-Control': 'public, s-max-age=600',
'Content-Type': 'application/json'
},
body: JSON.stringify(await getData())
};
} catch (error) {
return {
statusCode: 500,
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
error: true,
message: error.message
})
};
}
};
module.exports = sendJson;