diff --git a/API_TRANSITION_GUIDE.md b/API_TRANSITION_GUIDE.md index 4370a732..f968e902 100644 --- a/API_TRANSITION_GUIDE.md +++ b/API_TRANSITION_GUIDE.md @@ -59,8 +59,9 @@ const { emitterFor, Mode } = require("cloudevents"); function sendWithAxios(message) { // Do what you need with the message headers // and body in this function, then send the - // event - axios({ + // event. Return the promise so that `await emit(event)` + // waits for the send and rejects if it fails. + return axios({ method: 'post', url: '...', data: message.body, @@ -81,8 +82,9 @@ const { emitterFor, Mode, CloudEvent, Emitter } = require("cloudevents"); function sendWithAxios(message) { // Do what you need with the message headers // and body in this function, then send the - // event - axios({ + // event. Return the promise so that `await emit(event)` + // waits for the send and rejects if it fails. + return axios({ method: "post", url: "...", data: message.body, diff --git a/README.md b/README.md index b40b8de3..abac1560 100644 --- a/README.md +++ b/README.md @@ -91,8 +91,9 @@ const { emitterFor, Mode, CloudEvent } = require("cloudevents"); function sendWithAxios(message) { // Do what you need with the message headers // and body in this function, then send the - // event - axios({ + // event. Return the promise so that `await emit(event)` + // waits for the send and rejects if it fails. + return axios({ method: "post", url: "...", data: message.body,