Skip to content

Commit

Permalink
fix: return JSON in Node.js event template
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
lance committed Nov 5, 2020
1 parent ddbb95b commit 597fc8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkged.go

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions templates/node/events/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ const { CloudEvent, HTTP } = require('cloudevents');
*
* const incomingEvent = context.cloudevent;
*
* @param {Context} context the invocation context
* @param {Object} user the CloudEvent data. If the data content type is application/json
* this will be converted to an Object via JSON.parse()
* @param {Context} context the invocation context
*/
function verifyUser(context, user) {
if (!context.cloudevent) {
return 'No cloud event received';
return {
message: 'No cloud event received'
};
}

context.log.info('Processing user', user);
Expand Down

0 comments on commit 597fc8e

Please sign in to comment.