Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return JSON in Node.js event template #211

Merged
merged 1 commit into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, what if it returned:

return '"No cloud event received"'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would probably parse correctly by the browser.

};
}

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