Skip to content

Commit beb838f

Browse files
authored
fix: return JSON in Node.js event template (#211)
The event template was just returning a string, but the default response content type is application/json so browsers were failing to parse the string as JSON. Signed-off-by: Lance Ball <lball@redhat.com>
1 parent 470ebb9 commit beb838f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

pkged.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/node/events/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ const { CloudEvent, HTTP } = require('cloudevents');
1919
*
2020
* const incomingEvent = context.cloudevent;
2121
*
22+
* @param {Context} context the invocation context
2223
* @param {Object} user the CloudEvent data. If the data content type is application/json
2324
* this will be converted to an Object via JSON.parse()
24-
* @param {Context} context the invocation context
2525
*/
2626
function verifyUser(context, user) {
2727
if (!context.cloudevent) {
28-
return 'No cloud event received';
28+
return {
29+
message: 'No cloud event received'
30+
};
2931
}
3032

3133
context.log.info('Processing user', user);

0 commit comments

Comments
 (0)