async function publishMessage()

in order-service/index.js [204:214]


async function publishMessage(data) {
  try {
    const dataBuffer = Buffer.from(JSON.stringify(data))
    const messageId = await pubsub
        .topic(TOPIC_NAME)
        .publishMessage({data: dataBuffer});
    console.log(`Message ${messageId} published.`);
  } catch (error) {
    console.error(`Received error while publishing: ${error.message}`);
  }
}