Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Created July 18, 2021 17:08
Show Gist options
  • Save jamesseanwright/9cacac640bd4d200ddf7fd5ddbf0f728 to your computer and use it in GitHub Desktop.
Save jamesseanwright/9cacac640bd4d200ddf7fd5ddbf0f728 to your computer and use it in GitHub Desktop.
'use strict';
function invoke(r) {
var payload = {
body: r.requestText,
queryStringParameters: r.args,
};
r.subrequest('/integration', {
method: 'POST',
body: JSON.stringify(payload),
}).then(function (res) {
try {
var integrationRes = JSON.parse(res.responseText);
for (var headerName in integrationRes.headers) {
r.headersOut[headerName] = integrationRes.headers[headerName];
}
r.return(integrationRes.statusCode, integrationRes.body);
} catch (e) {
r.return(500, e.message);
}
});
}
// `export default function (){}` isn't supported
export default { invoke };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment