Created
July 18, 2021 17:08
-
-
Save jamesseanwright/9cacac640bd4d200ddf7fd5ddbf0f728 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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